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

前端之家收集整理的这篇文章主要介绍了unix – 杀死一个Haskell二进制文件前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如果我按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处理程序.我不知道是否有其他的信号处理程序隐藏在源代码中.

猜你在找的Bash相关文章