-SIGCONT不继续暂停的过程吗? [英] -SIGCONT does not continue paused process?

查看:49
本文介绍了-SIGCONT不继续暂停的过程吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从另一个终端运行 kill -SIGCONT pid 后,以下过程不会继续.

The following process does not continue after running kill -SIGCONT pid from another terminal.

#include <stdio.h>

int main(int argc, char *argv[])
{
    printf("paused\n");
    pause();
    printf("continue\n");

    return 0;
}

我希望程序在发送信号并打印继续"之后继续执行.为什么这不能按预期工作?

I expect the program to continue after sending the signal and printing "continue". How come this doesn't work as expected?

推荐答案

pause()被记录到

使调用进程(或线程)进入睡眠状态,直到传递了终止该进程或导致该进程的信号信号捕捉功能的调用.

cause the calling process (or thread) to sleep until a signal is delivered that either terminates the process or causes the invocation of a signal-catching function.

但是 SIGCONT 仅继续执行先前由SIGSTOP或SIGTSTP停止的过程.

But SIGCONT only continues a process previously stopped by SIGSTOP or SIGTSTP.

因此,您可能要尝试:

 kill(getpid(), SIGSTOP);

代替您的 pause()

此外,您可能希望查看 sigsuspend() .

Also, you might want to look at sigsuspend().

这篇关于-SIGCONT不继续暂停的过程吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆