Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!rutgers!cmcl2!husc6!ogccse!schaefer From: schaefer@ogccse.ogc.edu (Barton E. Schaefer) Newsgroups: comp.unix.questions Subject: Re: Login shell? Message-ID: <1829@ogccse.ogc.edu> Date: 25 Oct 88 15:49:16 GMT References: <314@uplog.se> <842@philmds.UUCP> <11@elgar.UUCP> <844@philmds.UUCP> Reply-To: schaefer@ogccse.UUCP (Barton E. Schaefer) Organization: Oregon Graduate Center, Beaverton, OR Lines: 27 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@cse.ogc.edu UUCP (Should work now) ...{sun,tektronix,verdix}!ogccse!schaefer