加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

unix – 杀死一个Haskell二进制文件

发布时间:2020-12-15 18:51:51 所属栏目:安全 来源:网络整理
导读:如果我按Ctrl C,这将抛出异常(总是在线程0?).如果你想要 – 或者更有可能运行一些清理,然后再推翻它,你可以抓住这个.但通常的结果是使程序以某种方式停止. 现在假设我使用了Unix kill命令.据了解,kill基本上会向指定的进程发送一个(可配置的)Unix信号. Hask
如果我按Ctrl C,这将抛出异常(总是在线程0?).如果你想要 – 或者更有可能运行一些清理,然后再推翻它,你可以抓住这个.但通常的结果是使程序以某种方式停止.

现在假设我使用了Unix kill命令.据了解,kill基本上会向指定的进程发送一个(可配置的)Unix信号.

Haskell RTS如何回应?是否记录在某个地方?我会想象发送SIGTERM将具有与Ctrl C相同的效果,但我不知道一个事实…

(当然,你可以使用kill来发送与杀戮毫无关系的信号,同样,我想象RTS会忽略SIGHUP或SIGPWR,但我不知道.)

在 ghc source code的github上搜索“signal”显示了 installDefaultSignals的功能:
void
initDefaultHandlers(void)
{
    struct sigaction action,oact;

    // install the SIGINT handler
    action.sa_handler = shutdown_handler;
    sigemptyset(&action.sa_mask);
    action.sa_flags = 0;
    if (sigaction(SIGINT,&action,&oact) != 0) {
sysErrorBelch("warning: failed to install SIGINT handler");
    }

#if defined(HAVE_SIGINTERRUPT)
    siginterrupt(SIGINT,1);    // isn't this the default? --SDM
#endif

    // install the SIGFPE handler

    // In addition to handling SIGINT,also handle SIGFPE by ignoring it.
    // Apparently IEEE requires floating-point exceptions to be ignored by
    // default,but alpha-dec-osf3 doesn't seem to do so.

    // Commented out by SDM 2/7/2002: this causes an infinite loop on
    // some architectures when an integer division by zero occurs: we
    // don't recover from the floating point exception,and the
    // program just generates another one immediately.
#if 0
    action.sa_handler = SIG_IGN;
    sigemptyset(&action.sa_mask);
    action.sa_flags = 0;
    if (sigaction(SIGFPE,&oact) != 0) {
    sysErrorBelch("warning: failed to install SIGFPE handler");
}
#endif

#ifdef alpha_HOST_ARCH
    ieee_set_fp_control(0);
#endif

    // ignore SIGPIPE; see #1619
    // actually,we use an empty signal handler rather than SIG_IGN,// so that SIGPIPE gets reset to its default behaviour on exec.
    action.sa_handler = empty_handler;
    sigemptyset(&action.sa_mask);
    action.sa_flags = 0;
    if (sigaction(SIGPIPE,&oact) != 0) {
sysErrorBelch("warning: failed to install SIGPIPE handler");
    }

    set_sigtstp_action(rtsTrue);
}

从那里可以看出,GHC至少安装了SIGINT和SIGPIPE处理程序.我不知道是否有其他的信号处理程序隐藏在源代码中.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读