?? signal.pm
字號:
package Thread::Signal;use Thread qw(async);=head1 NAMEThread::Signal - Start a thread which runs signal handlers reliably=head1 SYNOPSIS use Thread::Signal; $SIG{HUP} = \&some_handler;=head1 DESCRIPTIONThe C<Thread::Signal> module starts up a special signal handler thread.All signals to the process are delivered to it and it runs theassociated C<$SIG{FOO}> handlers for them. Without this module,signals arriving at inopportune moments (such as when perl's internalsare in the middle of updating critical structures) cause the perlcode of the handler to be run unsafely which can cause memory corruptionor worse.=head1 BUGSThis module changes the semantics of signal handling slightly in thatthe signal handler is run separately from the main thread (and inparallel with it). This means that tricks such as calling C<die> froma signal handler behave differently (and, in particular, can't beused to exit directly from a system call).=cutif (!init_thread_signals()) { require Carp; Carp::croak("init_thread_signals failed: $!");}async { my $sig; while ($sig = await_signal()) { &$sig(); }};END { kill_sighandler_thread();}1;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -