Login shell?
Leo de Wit
leo at philmds.UUCP
Sun Oct 23 03:32:20 AEST 1988
In article <314 at uplog.se> thomas at uplog.UUCP (Thomas Hameenaho) writes:
|One way of deciding wether or not the current shell is the login shell
|is the fact that the name of the login shell is prependended with a '-'.
|If for instance I run tcsh as my login shell it will be exec:ed with
|-tcsh as argv[0].
|
|Just take the output from ps -x (or -f if on system V) grep for pid $$
|and check if the command name begins with a '-'. If that is the case the
|shell is the login shell.
Two problems:
1) When I execl("/bin/sh","-sh",(char *)0); from within a C program I
also have a shell whose name starts with '-' (it will consequently try
to read a .profile file in the current directory, have you ever tried
that?). This is not a login shell (unless the C program is called login
8-).
2) When I exec a shell in my .profile file (for instance if I want my
own shell instead of /bin/sh or /bin/csh and don't want to bother my
system manager), this shell doesn't start with '-'. You could argue
about it, but I would like to consider this a login shell (the other
'login shell' has in fact also little to do with login, except for the
fact that it is exec'ed from login, but then, this one is too).
Leo.
More information about the Comp.unix.questions
mailing list