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
The sigstop is a signal which is used with the KILL command to stop the process for some time instead of terminating it permanently; the process can be resumed by using the sigcont command.
There is no key combination to send SIGSTOP. Control-S tells the terminal driver to suspend output, but does not send a signal to the process. Control-Q resumes output.
You cannot catch SIGSTOP. The page you referenced was mistaken. Try sending it the KILL and STOP signals, you will see that the process dies and halts, respectively, without the message being printed. If you try any other caught signal, you will see those are handled as expected.
When a child process stops or terminates, SIGCHLD is sent to the parent process. The default response to the signal is to ignore it. The signal can be caught and the exit status from the child process can be obtained by immediately calling wait(2) and wait3(3C).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With