On 07/26/2009 05:52 AM, Per Jessen wrote:
I'm forking a process, then waiting to pick it up with
waitpid(-1,0,WNOHANG)
but waitpid() returns -1 and error 10: No child processes ??
I suspect this may be somehow system/kernel dependent, coz' I have such code in a few places and it has always worked just fine, i.e. returned 0 when no child existed or had exited.
I have a SIGCHLD signal handler, which just increments a counter. When the counter is >0, I call waitpid().
I obviously googled this, and came across a few hits, but nothing really useful.
I'm pretty sure that waitpid() will return -1 if executed after your
signal handler. The SIGCHLD signal handler may be used to clear the
child state so that you do not have a zombie. I have some code hanging
around that is similar to yours but I have not tested it in years.
--
Jerry Feldman