Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 declare the SIGSTOP handler in the child? I have searched everywhere and not been able to find this information.

Thanks. Braden

like image 524
Braden Avatar asked Oct 03 '10 19:10

Braden


People also ask

Does SIGSTOP terminate process?

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.

How do I send SIGSTOP?

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.

Can SIGSTOP be trapped?

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.

What signal is sent to process when its child process stops?

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).


1 Answers

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.

like image 140
Jonathan Leffler Avatar answered Sep 21 '22 04:09

Jonathan Leffler