向子进程发送 SIGSTOP 会停止所有执行。 C
当我从父进程调用 kill(Child_PID, SIGSTOP);
时,我希望子进程停止执行,而父进程继续执行。这是预期的行为还是我必须在子进程中显式声明 SIGSTOP 处理程序?我到处搜索都没有找到这个信息。
谢谢。 布雷登
When I call kill(Child_PID, SIGSTOP);
from the parent, I expect the child to halt execution and the parent to continue. Is that the expected behavior or do I have to explicitly declare the SIGSTOP handler in the child? I have searched everywhere and not been able to find this information.
Thanks.
Braden
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
POSIX 说:
因此,如果信号发送成功,孩子别无选择,只能停止。并且您不能在子(或父或任何其他)进程中设置 SIGSTOP 处理程序。
POSIX says:
So, the child has no option but to stop - if the signal is sent successfully. And you cannot set a SIGSTOP handler in the child (or parent, or any other) process.
这是预期的行为。
使用
strace your_program
查看发生了什么。This is the expected behavior.
Use
strace your_program
to see what's happening.这是预期的行为。引用unix手册页:
BSD 手册页提到:
最后,您不允许安装 SIGSTOP 处理程序。并且进程将保持挂起状态,直到收到
SIGCONT
。That's the expected behaviour. Quoting from the unix man page:
And the BSD man page mentions that:
Concluding, you're not permitted to install a handler for SIGSTOP. And the process will remain in the suspended state until it receives a
SIGCONT
.