[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: Question
From:       Bob Dunlop <bob.dunlop () xyzzy ! org ! uk>
Date:       2013-12-05 12:46:19
Message-ID: 20131205124619.GA22209 () xyzzy ! org ! uk
[Download RAW message or body]


On Thu, Dec 05 at 01:10, snoweyes wrote:
> when you use busybox command , eg udhcpc
> you can not get the right pid number in the udhcpc_main function.
> when you use getpid() to get a value 495 , but the real num is 499 maybe.

I'm not sure I see the problem.

After startup udhcpc_main() calls write_pidfile() directly and it writes
the current PID.

Then if it needs to run daemonised it calls the routine client_background()
which calls bb_daemonize() to create a new process, and then calls
write_pidfile() again to update the PID file with the new child process ID.

If you run getpid() before the daemonise call you'll get the original
"parent" ID, run it after the daemonise call you get the "child" ID.
Both IDs are correct for different purposes.

-- 
        Bob Dunlop
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic