也从子进程收到 SIGINT

发布于 2024-12-14 08:14:46 字数 316 浏览 7 评论 0原文

我有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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

南烟 2024-12-21 08:14:46

子进程 (D) 应通过调用 setsid(2) 取消与控制终端的关联。

The child process (D) should disassociate from the controlling terminal by calling setsid(2).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文