Login shell?
James Logan III
logan at vsedev.VSE.COM
Tue Nov 8 09:55:16 AEST 1988
In article <1623 at solo10.cs.vu.nl> maart at cs.vu.nl (Maarten Litmaath) writes:
>In article <1217 at vsedev.VSE.COM> logan at vsedev.VSE.COM (James Logan III) writes:
>\... If you just want to find out what if the current
>\shell is indeed the shell spawned by init(1M) (via getty(1M), login(1)),
>\then just write a simple C program like this:
>\--------
>\#include <stdio.h>
>\
>\main()
>\{
>\ if (getppid() == getpgrp())
>\ exit(0);
>\ exit(1);
>\}
>
>1)
> Why #include <stdio.h>?
It's not necessary, I just always need it when I don't already have it,
so it's just a habit, I guess. It doesn't hurt anything and it will only
take a fraction of a second longer to compile it. In addition, if he
adds an fprintf(), the program won't compile without it since the
type "FILE" will be undefined.
I wouldn't suggest #including every header file you might ever need,
but this one is so often used, why not?
>2)
> This scheme won't work for rsh/rlogin.
It works just fine for rlogin, thank you. I just tested it on my
system.
Since you don't have a true session with rsh it will indicate
correctly that the program running is not your login shell.
-Jim
--
Jim Logan logan at vsedev.vse.com
(703) 892-0002 uucp: ..!uunet!vsedev!logan
inet: logan%vsedev.vse.com at uunet.uu.net
More information about the Comp.unix.questions
mailing list