1 package Thread::Signal;
8 Thread::Signal - Start a thread which runs signal handlers reliably
14 $SIG{HUP} = \&some_handler;
18 The C<Thread::Signal> module starts up a special signal handler thread.
19 All signals to the process are delivered to it and it runs the
20 associated C<$SIG{FOO}> handlers for them. Without this module,
21 signals arriving at inopportune moments (such as when perl's internals
22 are in the middle of updating critical structures) cause the perl
23 code of the handler to be run unsafely which can cause memory corruption
28 This module changes the semantics of signal handling slightly in that
29 the signal handler is run separately from the main thread (and in
30 parallel with it). This means that tricks such as calling C<die> from
31 a signal handler behave differently (and, in particular, can't be
32 used to exit directly from a system call).
36 if (!init_thread_signals()) {
38 Carp::croak("init_thread_signals failed: $!");
43 while ($sig = await_signal()) {
49 kill_sighandler_thread();