… | |
… | |
349 | my (undef, %arg) = @_; |
349 | my (undef, %arg) = @_; |
350 | |
350 | |
351 | my $signal = uc $arg{signal} |
351 | my $signal = uc $arg{signal} |
352 | or Carp::croak "required option 'signal' is missing"; |
352 | or Carp::croak "required option 'signal' is missing"; |
353 | |
353 | |
354 | $SIG_CB{$signal}{$arg{cb}} = $arg{cb}; |
354 | $SIG_CB{$signal}{$arg{cb} += 0} = $arg{cb}; |
355 | $SIG{$signal} ||= sub { |
355 | $SIG{$signal} ||= sub { |
356 | $_->() for values %{ $SIG_CB{$signal} || {} }; |
356 | $_->() for values %{ $SIG_CB{$signal} || {} }; |
357 | }; |
357 | }; |
358 | |
358 | |
359 | bless [$signal, $arg{cb}], "AnyEvent::Base::Signal" |
359 | bless [$signal, $arg{cb}], "AnyEvent::Base::Signal" |
… | |
… | |
374 | our $PID_IDLE; |
374 | our $PID_IDLE; |
375 | our $WNOHANG; |
375 | our $WNOHANG; |
376 | |
376 | |
377 | sub _child_wait { |
377 | sub _child_wait { |
378 | while (0 < (my $pid = waitpid -1, $WNOHANG)) { |
378 | while (0 < (my $pid = waitpid -1, $WNOHANG)) { |
379 | $_->() for values %{ (delete $PID_CB{$pid}) || {} }; |
379 | $_->() for values %{ $PID_CB{$pid} || {} }, %{ $PID_CB{0} || {} }; |
380 | } |
380 | } |
381 | |
381 | |
382 | undef $PID_IDLE; |
382 | undef $PID_IDLE; |
383 | } |
383 | } |
384 | |
384 | |