The Wikipedia page for SIGCHLD says:
The SIGCHLD signal is sent to the parent of a child process when it exits, is interrupted, or resumes after being interrupted.
Does that mean that when the parent process sends any signal (such as SIGTERM
) to the child process, it will in turn receive a SIGCHLD
back from the child?
Or do I misinterpret interrupt (I assume it to mean any signal received), in this case, which signals are concerned?
The SIGTERM signal is a generic signal used to cause program termination. Unlike SIGKILL , this signal can be blocked, handled, and ignored.
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).
Define a handler for SIGCHLD that calls waitpid This allows for the possibility of SIGCHLD being raised for reasons other than the termination of a child process. ( SIGCHLD has three conventional uses: to indicate that a child process has terminated, stopped or continued.
Note that the default action for SIGCHLD is to ignore this signal; nevertheless signal(SIGCHLD, SIG_IGN) has effect, namely that of preventing the transformation of children into zombies.
A SIGCHLD is delivered to the parent in these cases:
I would presume the SIGSTOP/SIGCONT is what wikipedia means by "interrupted".
The default handler for SIGTERM is to terminate the process. So if the parent sends SIGTERM to the child process which terminates that child, then yes - the parent will receive a SIGCHLD.
If the child installs a signal handler that does not terminate it, there will be no SIGCHLD signal delivered to the parent.
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