… | |
… | |
40 | }; |
40 | }; |
41 | |
41 | |
42 | # CHILD/PID STATUS CHANGES |
42 | # CHILD/PID STATUS CHANGES |
43 | |
43 | |
44 | my $w = EV::child 666, sub { |
44 | my $w = EV::child 666, sub { |
45 | my ($w, $revents, $status) = @_; |
45 | my ($w, $revents) = @_; |
|
|
46 | # my $pid = $w->rpid; |
|
|
47 | my $status = $w->rstatus; |
46 | }; |
48 | }; |
47 | |
49 | |
48 | # MAINLOOP |
50 | # MAINLOOP |
49 | EV::loop; # loop until EV::loop_done is called |
51 | EV::loop; # loop until EV::loop_done is called |
50 | EV::loop EV::LOOP_ONESHOT; # block until at least one event could be handled |
52 | EV::loop EV::LOOP_ONESHOT; # block until at least one event could be handled |
… | |
… | |
60 | package EV; |
62 | package EV; |
61 | |
63 | |
62 | use strict; |
64 | use strict; |
63 | |
65 | |
64 | BEGIN { |
66 | BEGIN { |
65 | our $VERSION = '0.1'; |
67 | our $VERSION = '0.51'; |
66 | use XSLoader; |
68 | use XSLoader; |
67 | XSLoader::load "EV", $VERSION; |
69 | XSLoader::load "EV", $VERSION; |
68 | } |
70 | } |
69 | |
71 | |
70 | @EV::Io::ISA = |
72 | @EV::Io::ISA = |
… | |
… | |
356 | Call the callback when a status change for pid C<$pid> (or any pid |
358 | Call the callback when a status change for pid C<$pid> (or any pid |
357 | if C<$pid> is 0) has been received. More precisely: when the process |
359 | if C<$pid> is 0) has been received. More precisely: when the process |
358 | receives a SIGCHLD, EV will fetch the outstanding exit/wait status for all |
360 | receives a SIGCHLD, EV will fetch the outstanding exit/wait status for all |
359 | changed/zombie children and call the callback. |
361 | changed/zombie children and call the callback. |
360 | |
362 | |
361 | Unlike all other callbacks, this callback will be called with an |
363 | You can access both status and pid by using the C<rstatus> and C<rpid> |
362 | additional third argument which is the exit status. See the C<waitpid> |
364 | methods on the watcher object. |
363 | function for details. |
|
|
364 | |
365 | |
365 | You can have as many pid watchers per pid as you want. |
366 | You can have as many pid watchers per pid as you want. |
366 | |
367 | |
367 | The C<child_ns> variant doesn't start (activate) the newly created watcher. |
368 | The C<child_ns> variant doesn't start (activate) the newly created watcher. |
368 | |
369 | |
… | |
… | |
374 | =item $current_pid = $w->pid |
375 | =item $current_pid = $w->pid |
375 | |
376 | |
376 | =item $old_pid = $w->pid ($new_pid) |
377 | =item $old_pid = $w->pid ($new_pid) |
377 | |
378 | |
378 | Returns the previously set process id and optionally set a new one. |
379 | Returns the previously set process id and optionally set a new one. |
|
|
380 | |
|
|
381 | =item $exit_status = $w->rstatus |
|
|
382 | |
|
|
383 | Return the exit/wait status (as returned by waitpid, see the waitpid entry |
|
|
384 | in perlfunc). |
|
|
385 | |
|
|
386 | =item $pid = $w->rpid |
|
|
387 | |
|
|
388 | Return the pid of the awaited child (useful when you have installed a |
|
|
389 | watcher for all pids). |
379 | |
390 | |
380 | |
391 | |
381 | =item $w = EV::idle $callback |
392 | =item $w = EV::idle $callback |
382 | |
393 | |
383 | =item $w = EV::idle_ns $callback |
394 | =item $w = EV::idle_ns $callback |
… | |
… | |
464 | |
475 | |
465 | our $DIED = sub { |
476 | our $DIED = sub { |
466 | warn "EV: error in callback (ignoring): $@"; |
477 | warn "EV: error in callback (ignoring): $@"; |
467 | }; |
478 | }; |
468 | |
479 | |
469 | init; |
480 | default_loop |
|
|
481 | or die 'EV: cannot initialise libev backend. bad $ENV{LIBEV_METHODS}?'; |
470 | |
482 | |
471 | push @AnyEvent::REGISTRY, [EV => "EV::AnyEvent"]; |
483 | push @AnyEvent::REGISTRY, [EV => "EV::AnyEvent"]; |
472 | |
484 | |
473 | 1; |
485 | 1; |
474 | |
486 | |