【问题标题】:Signal SIGSTOP received, but no signal handler set in perl script收到信号 SIGSTOP,但在 perl 脚本中没有设置信号处理程序
【发布时间】:2013-07-30 16:30:12
【问题描述】:

我的 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 脚本中没有设置信号处理程序。我哪里出错了?

【问题讨论】:

  • Don't use prototypes -- 将 Perl 的 subs 声明为 sub name { ... } 而不是 sub name() { ... }
  • 你在什么平台上运行这个?我认为您的问题是您无法捕获 STOPKILL 信号。
  • 我正在Linux上尝试上面的代码

标签: multithreading perl signals


【解决方案1】:

你应该设置$SIG{STOP},而不是$SIG{SIGSTOP}

如果您use warnings,您会收到有关此错误的警报。如果您use diagnostics,您会得到一些实用的建议,了解导致错误的原因以及如何修复它。

【讨论】:

  • 如果我添加使用警告并使用诊断也无济于事
猜你喜欢
  • 1970-01-01
  • 2023-03-06
  • 1970-01-01
  • 2017-04-02
  • 1970-01-01
  • 2023-03-20
  • 1970-01-01
  • 2013-06-19
  • 2021-11-06
相关资源
最近更新 更多