tags:

views:

31

answers:

3

Hi, My app now has been sealed as a product, which will be sold with a PC with linux system installed. How ever I will create a new user for the customers, but I want bind a interface-like app to the user, so when my custumers log in via terminals the selected app runs automatically, when connection ends, the app quit the same way. I know , maybe this can be implemented programmally..but... Do you know any suggestion??? thanx all appreciated...

A: 

If you have your app started by xinetd then you can have it start up on connect. On disconnect your app will be sent a SIGHUP, so you can catch that and shut down.

Ignacio Vazquez-Abrams
could provide more detailed information? thx
Macroideal
Programs started by `xinetd` have their stdin and stdout connected to the network socket, so they can use the standard C I/O functions to communicate with the client instead of having to deal with the socket directly.
Ignacio Vazquez-Abrams
A: 

The program executed by terminal login is the user shell as determined by a field in /etc/passwd. You could either put your program as the shell, or arrange for you program to be executed by the shell start up scripts (~/.profile, ~/.cshrc depending on the shell).

AProgrammer
@AProgrammer can you give me some examples. thx
Macroideal
+1  A: 

As mentioned by AProgrammer you can run your app as the user shell or in the profile, as in this example

# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
    . "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

# run you app here
exec myapp
dtmilano