我的 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, $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 信号发送到线程。正是在这一点上,执行停止并且我收到错误“收到信号 SIGSTOP,但在 perl 脚本中没有设置信号处理程序。我哪里出错了?