--- AnyEvent/lib/AnyEvent.pm 2009/07/18 15:51:52 1.246 +++ AnyEvent/lib/AnyEvent.pm 2009/07/18 22:24:17 1.247 @@ -370,8 +370,14 @@ so programs overwriting those signals directly will likely not work correctly. -Also note that many event loops (e.g. Glib, Tk, Qt, IO::Async) do not -support attaching callbacks to signals, which is a pity, as you cannot do +Example: exit on SIGINT + + my $w = AnyEvent->signal (signal => "INT", cb => sub { exit 1 }); + +=head3 Signal Races, Delays and Workarounds + +Many event loops (e.g. Glib, Tk, Qt, IO::Async) do not support attaching +callbacks to signals in a generic way, which is a pity, as you cannot do race-free signal handling in perl. AnyEvent will try to do it's best, but in some cases, signals will be delayed. The maximum time a signal might be delayed is specified in C<$AnyEvent::MAX_SIGNAL_LATENCY> (default: 10 @@ -379,11 +385,10 @@ watcher is created, and should be left alone otherwise. Higher values will cause fewer spurious wake-ups, which is better for power and CPU saving. All these problems can be avoided by installing the optional -L module. - -Example: exit on SIGINT - - my $w = AnyEvent->signal (signal => "INT", cb => sub { exit 1 }); +L module. This will not work with inherently broken +event loops such as L or L (and not with L +currently, as POE does it's own workaround with one-second latency). With +those, you just have to suffer the delays. =head2 CHILD PROCESS WATCHERS @@ -2272,7 +2277,7 @@ my knowledge, there is no way to do completely race-free and quick signal handling in pure perl. To ensure that signals still get delivered, AnyEvent will start an interval timer to wake up perl (and -catch the signals) with soemd elay (default is 10 seconds, look for +catch the signals) with some delay (default is 10 seconds, look for C<$AnyEvent::MAX_SIGNAL_LATENCY>). If this module is available, then it will be used to implement signal @@ -2283,6 +2288,11 @@ This affects not just the pure-perl event loop, but also other event loops that have no signal handling on their own (e.g. Glib, Tk, Qt). +Some event loops (POE, Event, Event::Lib) offer signal watchers natively, +and either employ their own workarounds (POE) or use AnyEvent's workaround +(using C<$AnyEvent::MAX_SIGNAL_LATENCY>). Installing L +does nothing for those backends. + =item L This module isn't really "optional", as it is simply one of the backend