Multithreading 接收到信号SIGSTOP,但在perl脚本中未设置信号处理程序
我的perl脚本中有以下代码,但似乎无法正常工作:Multithreading 接收到信号SIGSTOP,但在perl脚本中未设置信号处理程序,multithreading,perl,signals,Multithreading,Perl,Signals,我的perl脚本中有以下代码,但似乎无法正常工作: my $thr; sub start__server_thread() { $thr = threads->create(\&iperf_start_server, $_[0], $_[1], $_[2]); print("Value of thread is $thr\n"); &START_SERVER_RESPONSE($controller_ip, $control
my $thr;
sub start__server_thread()
{
$thr = threads->create(\&iperf_start_server, $_[0], $_[1], $_[2]);
print("Value of thread is $thr\n");
&START_SERVER_RESPONSE($controller_ip, $controller_port, "success", 2345, $_[1]);
}
sub iperf_start_server()
{
# Do some stuff here and then handle the signal
$SIG{'SIGSTOP'} = sub {
print("Stop signal received\n");
$thr->exit();
$flag = 1;
};
}
sub stop_server()
{
my ($dat,$filelog,$result);
$thr->kill('STOP');
$flag = 1;
sleep(10);
$thr->exit(1);
}
当从其他上下文调用stop_server()时,它会尝试向线程发送SIGSTOP信号。正是在这一点上,执行停止,我得到了错误“Signal SIGSTOP received,但没有在perl脚本中设置信号处理程序。我哪里出错了?您应该设置
$SIG{STOP}
,而不是$SIG{SIGSTOP}
如果您
使用警告
,您将收到此错误的警报。如果您使用诊断
,您将得到一些关于错误原因和修复方法的实用建议。您应该设置$SIG{STOP}
,而不是$SIG{SIGSTOP}
如果您
使用警告
,您将收到此错误的警告。如果您使用诊断
,您将得到一些关于错误原因和修复方法的实用建议。--将Perl sub声明为sub-name{…}
而不是sub-name(){…}
。您在什么平台上运行此操作?我认为您的问题是无法捕获停止
或终止
信号。我正在Linux上尝试上述代码--将Perl sub声明为sub-name{…}
而不是sub-name(){…}
。您在什么平台上运行此操作?我认为您的问题是无法捕获停止
或终止
信号。我正在Linux上尝试上述代码,如果我添加使用警告和使用诊断,则这些代码没有帮助。如果我添加使用警告和使用诊断,则这些代码没有帮助