也从子进程收到 SIGINT
我有2个程序(由我编写)。第一个名为“MAN”的进程将调用“D”(第二个进程),该进程将在后台运行,直到以某种方式终止。
我想终止 MAN 而不终止 D。
我尝试使用 ctrl + c 终止 MAN,它正确终止了 man(我拦截了 sigint 信号),现在我希望 D 继续运行,但是当 MAN 接收到 CTRL + C 时,D 接收它也是。
遇到这种情况该如何处理呢?重要的是,我想保留仅运行 D 并用 CTRL + C 终止的可能性。当我通过 MAN 运行它时,问题就出现了,我不想用 CTRL + C 终止它,它应该只到达 MAN。
有什么建议吗?
I have 2 programs (written by me). The first one called "MAN" will invoke "D" (the second one) which is a process that will run in background until terminated in some ways.
I would like to terminate MAN without terminating D.
I try to terminate MAN using ctrl + c and it terminates man correctly (I intercepted the sigint signal), now I want that D keeps running, however when MAN receives CTRL + C, D receive it too.
How to handle this situation? It's important that I would like to keep the possibility to run only D and terminate with CTRL + C. The problem comes when I run it through MAN, I don't want to terminate it with CTRL + C which should reach MAN only.
Any suggestion?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
子进程 (D) 应通过调用
setsid(2)
取消与控制终端的关联。The child process (D) should disassociate from the controlling terminal by calling
setsid(2)
.