[prog] check if script parent process is "init"

Wolfgang Petzold petzold at villa-chaos.de
Thu Apr 15 12:58:27 EST 2004

John Clarke wrote:

> $PPID should always be set, but it won't be 1. [...]
> So when the scripts are run, they'll have $PPID set to the pid of the
> shell which is running /etc/rc.d/rc.

Well ... that is a detail I didn't check. (Should have, though ...) I 
have to admit, I was looking at the output of "ps -A" and it seemed that 
system daemons like atd, crond and the like (which are all undoubtedly 
started via the runlevel mechanism) had the immediate parent "init". 
Perhaps this is because the rc script that really started the daemons 
already finished?

Anyway, I guess that further details don't matter all too much to the 
subject, do they?

Thanks anyway,

PS. Another "should have": I should have checked the techtalk list first 
for existing answers before posting. So at least, I have finally 
subscribed to techtalk. Sorry if I caused confusion.

More information about the Programming mailing list