收到信号 SIGSTOP,但在 perl 脚本中没有设置信号处理程序 [英] Signal SIGSTOP received, but no signal handler set in perl script
问题描述
我的 perl 脚本中有以下代码似乎不起作用:
我的$thr;sub start__server_thread(){$thr = 线程->create(\&iperf_start_server, $_[0], $_[1], $_[2]);print("线程的值为$thr\n");&START_SERVER_RESPONSE($controller_ip, $controller_port, "success", 2345, $_[1]);}子 iperf_start_server(){# 在这里做一些事情然后处理信号$SIG{'SIGSTOP'} = sub {print("收到停止信号\n");$thr->exit();$标志= 1;};}sub stop_server(){我的 ($dat,$filelog,$result);$thr->kill('停止');$标志= 1;睡眠(10);$thr->exit(1);}
当从其他上下文调用 stop_server() 时,它会尝试向线程发送 SIGSTOP 信号.正是在这一点上,执行停止,我收到错误收到信号 SIGSTOP,但在 perl 脚本中没有设置信号处理程序.我哪里出错了?
您应该设置 $SIG{STOP}
,而不是 $SIG{SIGSTOP}
.>
如果您使用警告
,您会收到此错误的警报.如果您使用诊断
,您会得到一些关于导致错误的原因以及如何修复错误的实用建议.
I have the following code in my perl script which somehow doesn't seem to work:
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);
}
When from some other context stop_server() is called, it tries to send the SIGSTOP signal to the thread. It is at this point that the execution stops and I get the error "Signal SIGSTOP received, but no signal handler set in perl script. Where have i gone wrong?
You should be setting $SIG{STOP}
, not $SIG{SIGSTOP}
.
If you use warnings
, you would have been alerted to this error. And if you use diagnostics
, you would get some practical advice on what caused the error and how to fix it.
这篇关于收到信号 SIGSTOP,但在 perl 脚本中没有设置信号处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!