[opensuse-programming] waitpid() failed; error 10: No child processes
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. /Per Jessen, Zürich -- To unsubscribe, e-mail: opensuse-programming+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-programming+help@opensuse.org
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 <gaf@blu.org> Boston Linux and Unix PGP key id: 537C5846 PGP Key fingerprint: 3D1B 8377 A3C0 A5F2 ECBB CA3B 4607 4319 537C 5846
Jerry Feldman wrote:
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.
Yeah, I think you're right - I've been going over my old code, and I have a check for errno!=ECHILD. /Per Jessen, Zürich -- To unsubscribe, e-mail: opensuse-programming+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-programming+help@opensuse.org
participants (2)
-
Jerry Feldman
-
Per Jessen