How can one kill a process group safely, and force kill if needed?
The goal is to do a kill with SIGTERM (-15) then if the apps in the tree do not die after a timeout (e.g. 60 seconds) do a SIGKILL (-9).
We have a scenario with parent process and a child process, sharing a pgid, E.g
Parent Process pid=123, pgid=123 |- Child Process pid=456, pgid=123
Currently we are sending the SIGTERM (-15) to the process group, then if the parent process is dead, then assume success.
However, sometimes we found that the parent process dies, and the child process does not die.
So this boils down to two questions:
Why does the parent pid die if the child does not die (is this possible, or are my assumptions wrong)?
Would checking to see if there are any processes in the process group be the best way to make sure all the processes in the tree are dead before sending the kill -9 to the process group?