--- AnyEvent/lib/AnyEvent.pm 2007/11/02 19:12:02 1.30 +++ AnyEvent/lib/AnyEvent.pm 2007/11/02 19:20:36 1.31 @@ -176,8 +176,9 @@ =head2 CHILD PROCESS WATCHERS You can also listen for the status of a child process specified by the -C argument. The watcher will only trigger once. This works by -installing a signal handler for C. +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. Example: wait for pid 1333 @@ -351,7 +352,7 @@ my $signal = uc $arg{signal} or Carp::croak "required option 'signal' is missing"; - $SIG_CB{$signal}{$arg{cb} += 0} = $arg{cb}; + $SIG_CB{$signal}{$arg{cb}} = $arg{cb}; $SIG{$signal} ||= sub { $_->() for values %{ $SIG_CB{$signal} || {} }; }; @@ -376,7 +377,8 @@ sub _child_wait { while (0 < (my $pid = waitpid -1, $WNOHANG)) { - $_->() for values %{ $PID_CB{$pid} || {} }, %{ $PID_CB{0} || {} }; + $_->() for (values %{ $PID_CB{$pid} || {} }), + (values %{ $PID_CB{0} || {} }); } undef $PID_IDLE; @@ -385,7 +387,7 @@ sub child { my (undef, %arg) = @_; - my $pid = uc $arg{pid} + defined (my $pid = $arg{pid} + 0) or Carp::croak "required option 'pid' is missing"; $PID_CB{$pid}{$arg{cb}} = $arg{cb};