⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 signal.pm

📁 UNIX下perl实现代码
💻 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 + -