Problem with PPID

Denys Vlasenko vda.linux at googlemail.com
Sun Nov 4 13:56:53 UTC 2007


On Sunday 04 November 2007 12:07, Marc Blumentritt wrote:
> >> # Ensure we are called by init
> >> echo "PPID = $PPID"
> >> #[ "$PPID" == "1" ] || exit 0
> >>
> >> I would expect a PPID of 1, bit I get something like 833! But if a check
> >> with ps, init has PID of 1?! I cannot explain this. I also used sysvinit
> >> instead of bb init and checked PPID in a similar way and got the same
> >> result! The only idea I have, where this could come from is, that
> >> /bin/sh is of course a link to /bin/busybox. Perhaps this breaks
> >> checking PPID? Or this is some kind of bug? Or is this related with
> >> running a system in rootfs of initramfs?
> > 
> > I think that your process gets started from a child of init, not
> > from init itself. Do "ps -A" and send output to the list,
> > and alsoo look up what process has PID 833.
> 
> This is ps -A from booted system:
> root at mediamachine $ ps -A
> PID   USER     COMMAND
>     1 root     init
>     2 root     [kthreadd]
...
>  1381 root     ps -A
> 
> I do not see PID 833.
> 
> I also added
> ps -a > /ps_init_data to my init script

Yes, this is what I meant to do.

> and got this result(!):  
> root at mediamachine $ cat /ps_init_data
> PID   USER     COMMAND
> 
> Empty list? At least init should be listed, shouldn't it?

If /proc is not mounted, ps cannot retrieve process list.
Mount /proc first:

mount -t proc proc /proc
ps -a > /ps_init_data

--
vda



More information about the busybox mailing list