Sending SIGSTOP to a child process stops all execution. C
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 decl开发者_如何学JAVAare the SIGSTOP handler in the child? I have searched everywhere and not been able to find this information.
Thanks. Braden
POSIX says:
The system shall not allow a process to catch the signals SIGKILL and SIGSTOP.
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.
That's the expected behaviour. Quoting from the unix man page:
The signals SIGKILL and SIGSTOP cannot be caught, blocked, or ignored.
And the BSD man page mentions that:
The signal() function will fail and no action will take place if one of the following occur:
[EINVAL] The sig argument is not a valid signal number. [EINVAL] An attempt is made to ignore or supply a handler for SIGKILL or SIGSTOP.
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
.
This is the expected behavior.
Use strace your_program
to see what's happening.
精彩评论