ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/lib/AnyEvent.pm
(Generate patch)

Comparing AnyEvent/lib/AnyEvent.pm (file contents):
Revision 1.340 by root, Fri Dec 3 18:39:06 2010 UTC vs.
Revision 1.341 by root, Sun Dec 5 11:41:45 2010 UTC

1628# default implementation for ->child 1628# default implementation for ->child
1629 1629
1630our %PID_CB; 1630our %PID_CB;
1631our $CHLD_W; 1631our $CHLD_W;
1632our $CHLD_DELAY_W; 1632our $CHLD_DELAY_W;
1633our $WNOHANG;
1634 1633
1635# used by many Impl's 1634# used by many Impl's
1636sub _emit_childstatus($$) { 1635sub _emit_childstatus($$) {
1637 my (undef, $rpid, $rstatus) = @_; 1636 my (undef, $rpid, $rstatus) = @_;
1638 1637
1645 eval q{ # poor man's autoloading {} 1644 eval q{ # poor man's autoloading {}
1646 *_sigchld = sub { 1645 *_sigchld = sub {
1647 my $pid; 1646 my $pid;
1648 1647
1649 AnyEvent->_emit_childstatus ($pid, $?) 1648 AnyEvent->_emit_childstatus ($pid, $?)
1650 while ($pid = waitpid -1, $WNOHANG) > 0; 1649 while ($pid = waitpid -1, WNOHANG) > 0;
1651 }; 1650 };
1652 1651
1653 *child = sub { 1652 *child = sub {
1654 my (undef, %arg) = @_; 1653 my (undef, %arg) = @_;
1655 1654
1656 defined (my $pid = $arg{pid} + 0) 1655 defined (my $pid = $arg{pid} + 0)
1657 or Carp::croak "required option 'pid' is missing"; 1656 or Carp::croak "required option 'pid' is missing";
1658 1657
1659 $PID_CB{$pid}{$arg{cb}} = $arg{cb}; 1658 $PID_CB{$pid}{$arg{cb}} = $arg{cb};
1660
1661 # WNOHANG is almost cetrainly 1 everywhere
1662 $WNOHANG ||= $^O =~ /^(?:openbsd|netbsd|linux|freebsd|cygwin|MSWin32)$/
1663 ? 1
1664 : eval { local $SIG{__DIE__}; require POSIX; &POSIX::WNOHANG } || 1;
1665 1659
1666 unless ($CHLD_W) { 1660 unless ($CHLD_W) {
1667 $CHLD_W = AE::signal CHLD => \&_sigchld; 1661 $CHLD_W = AE::signal CHLD => \&_sigchld;
1668 # child could be a zombie already, so make at least one round 1662 # child could be a zombie already, so make at least one round
1669 &_sigchld; 1663 &_sigchld;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines