Login shell?
Barton E. Schaefer
schaefer at ogccse.ogc.edu
Wed Oct 26 01:49:16 AEST 1988
I've been watching this discussion with only moderate interest, but
the most recent couple of postings seem to have come full circle,
i.e., the argument has now become "but I can't look for a `-' in ps
because I might start a not-login shell whose name begins with `-'."
So I thought I'd throw in a semi-new suggestion.
I have no experience with SysV, so somebody else will have to tell
me if this does not work there. But on BSD, why not:
1) Use "ps xl" (produces the PARENT pid as well as the pid)
2) Grep for the pid
3) Check the parent pid; if `1', then you have a login shell
This will never identify a not-login shell as a login shell, but it
will fail to identify rlogin shells (whose ppid is that of the rlogin
daemon). Even that could be worked around if you use "ps axl" and
save the output in a file; once you have the ppid, grep for that, and
check the name of the parent process to see if it is "rlogind".
Anybody see any problems with this? I suppose technically that a
shell started with "exec" from a login shell is not exactly a login
shell, but you'd probably want it to behave like one, so this test
should be OK.
--
Bart Schaefer "You've heard of Load/Store architectures? Well, the
80286 is a L-l-l-load/S-s-s-store architecture."
CSNET (Has not changed) schaefer at cse.ogc.edu
UUCP (Should work now) ...{sun,tektronix,verdix}!ogccse!schaefer
More information about the Comp.unix.questions
mailing list