… | |
… | |
399 | my $w = AnyEvent->signal (signal => "INT", cb => sub { exit 1 }); |
399 | my $w = AnyEvent->signal (signal => "INT", cb => sub { exit 1 }); |
400 | |
400 | |
401 | =head3 Signal Races, Delays and Workarounds |
401 | =head3 Signal Races, Delays and Workarounds |
402 | |
402 | |
403 | Many event loops (e.g. Glib, Tk, Qt, IO::Async) do not support attaching |
403 | Many event loops (e.g. Glib, Tk, Qt, IO::Async) do not support attaching |
404 | callbacks to signals in a generic way, which is a pity, as you cannot do |
404 | callbacks to signals in a generic way, which is a pity, as you cannot |
405 | race-free signal handling in perl. AnyEvent will try to do it's best, but |
405 | do race-free signal handling in perl, requiring C libraries for |
|
|
406 | this. AnyEvent will try to do it's best, which means in some cases, |
406 | in some cases, signals will be delayed. The maximum time a signal might |
407 | signals will be delayed. The maximum time a signal might be delayed is |
407 | be delayed is specified in C<$AnyEvent::MAX_SIGNAL_LATENCY> (default: 10 |
408 | specified in C<$AnyEvent::MAX_SIGNAL_LATENCY> (default: 10 seconds). This |
408 | seconds). This variable can be changed only before the first signal |
409 | variable can be changed only before the first signal watcher is created, |
409 | watcher is created, and should be left alone otherwise. Higher values |
410 | and should be left alone otherwise. This variable determines how often |
|
|
411 | AnyEvent polls for signals (in case a wake-up was missed). Higher values |
410 | will cause fewer spurious wake-ups, which is better for power and CPU |
412 | will cause fewer spurious wake-ups, which is better for power and CPU |
|
|
413 | saving. |
|
|
414 | |
411 | saving. All these problems can be avoided by installing the optional |
415 | All these problems can be avoided by installing the optional |
412 | L<Async::Interrupt> module. This will not work with inherently broken |
416 | L<Async::Interrupt> module, which works with most event loops. It will not |
413 | event loops such as L<Event> or L<Event::Lib> (and not with L<POE> |
417 | work with inherently broken event loops such as L<Event> or L<Event::Lib> |
414 | currently, as POE does it's own workaround with one-second latency). With |
418 | (and not with L<POE> currently, as POE does it's own workaround with |
415 | those, you just have to suffer the delays. |
419 | one-second latency). For those, you just have to suffer the delays. |
416 | |
420 | |
417 | =head2 CHILD PROCESS WATCHERS |
421 | =head2 CHILD PROCESS WATCHERS |
418 | |
422 | |
419 | $w = AnyEvent->child (pid => <process id>, cb => <callback>); |
423 | $w = AnyEvent->child (pid => <process id>, cb => <callback>); |
420 | |
424 | |