in reply to How do you wait for a process to end ?
You're only waiting for one process to end, then removing ten entries in your array of pids. The waitpid call will return status for only one deceased process, but you clear your array of ten pids in response. (BTW, it's clearer to write @pids = () instead of $#pids = -1.)
Another way to structure this would be to set up a signal handler for SIGCHLD and issue a wait there. Something like this (untested):
sub reapchild { # already using POSIX, right?? 0 while waitpid(-1, &WNOHANG) > 0; } $SIG{CHLD} = \&reapchild;
HTH
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: How do you wait for a process to end ?
by jalebie (Acolyte) on Aug 23, 2001 at 19:03 UTC | |
by VSarkiss (Monsignor) on Aug 23, 2001 at 19:34 UTC | |
by claree0 (Hermit) on Aug 23, 2001 at 19:36 UTC |