… | |
… | |
471 | problems mentioned in the description of signal watchers apply. |
471 | problems mentioned in the description of signal watchers apply. |
472 | |
472 | |
473 | Example: fork a process and wait for it |
473 | Example: fork a process and wait for it |
474 | |
474 | |
475 | my $done = AnyEvent->condvar; |
475 | my $done = AnyEvent->condvar; |
476 | |
476 | |
477 | my $pid = fork or exit 5; |
477 | my $pid = fork or exit 5; |
478 | |
478 | |
479 | my $w = AnyEvent->child ( |
479 | my $w = AnyEvent->child ( |
480 | pid => $pid, |
480 | pid => $pid, |
481 | cb => sub { |
481 | cb => sub { |
482 | my ($pid, $status) = @_; |
482 | my ($pid, $status) = @_; |
483 | warn "pid $pid exited with status $status"; |
483 | warn "pid $pid exited with status $status"; |
484 | $done->send; |
484 | $done->send; |
485 | }, |
485 | }, |
486 | ); |
486 | ); |
487 | |
487 | |
488 | # do something else, then wait for process exit |
488 | # do something else, then wait for process exit |
489 | $done->recv; |
489 | $done->recv; |
490 | |
490 | |
491 | IDLE WATCHERS |
491 | IDLE WATCHERS |
492 | $w = AnyEvent->idle (cb => <callback>); |
492 | $w = AnyEvent->idle (cb => <callback>); |
493 | |
493 | |
… | |
… | |
1843 | |
1843 | |
1844 | You can make AnyEvent completely ignore this variable by deleting it |
1844 | You can make AnyEvent completely ignore this variable by deleting it |
1845 | before the first watcher gets created, e.g. with a "BEGIN" block: |
1845 | before the first watcher gets created, e.g. with a "BEGIN" block: |
1846 | |
1846 | |
1847 | BEGIN { delete $ENV{PERL_ANYEVENT_MODEL} } |
1847 | BEGIN { delete $ENV{PERL_ANYEVENT_MODEL} } |
1848 | |
1848 | |
1849 | use AnyEvent; |
1849 | use AnyEvent; |
1850 | |
1850 | |
1851 | Similar considerations apply to $ENV{PERL_ANYEVENT_VERBOSE}, as that can |
1851 | Similar considerations apply to $ENV{PERL_ANYEVENT_VERBOSE}, as that can |
1852 | be used to probe what backend is used and gain other information (which |
1852 | be used to probe what backend is used and gain other information (which |
1853 | is probably even less useful to an attacker than PERL_ANYEVENT_MODEL), |
1853 | is probably even less useful to an attacker than PERL_ANYEVENT_MODEL), |
1854 | and $ENV{PERL_ANYEVENT_STRICT}. |
1854 | and $ENV{PERL_ANYEVENT_STRICT}. |