--- AnyEvent/lib/AnyEvent.pm 2007/11/02 19:20:36 1.31 +++ AnyEvent/lib/AnyEvent.pm 2007/11/03 09:29:51 1.32 @@ -178,7 +178,8 @@ You can also listen for the status of a child process specified by the C argument (or any child if the pid argument is 0). The watcher will trigger as often as status change for the child are received. This works -by installing a signal handler for C. +by installing a signal handler for C. The callback will be called with +the pid and exit status (as returned by waitpid). Example: wait for pid 1333 @@ -376,9 +377,9 @@ our $WNOHANG; sub _child_wait { - while (0 < (my $pid = waitpid -1, $WNOHANG)) { - $_->() for (values %{ $PID_CB{$pid} || {} }), - (values %{ $PID_CB{0} || {} }); + while (0 <= (my $pid = waitpid -1, $WNOHANG)) { + $_->($pid, $?) for (values %{ $PID_CB{$pid} || {} }), + (values %{ $PID_CB{0} || {} }); } undef $PID_IDLE;