I need the ability to kill all child processes running under a particular parent. What would be the better option to do this? Using PPID or PGID?

Something like this:

pkill -TERM -P

Would kill childs using a PPID. But I have read bits and pieces here and there about PGID and am curious to know if one works better over the other.


Killing a parent process won't kill child processes unless the parent traps and resends the signal.

Killing a process group with TERM sends the TERM signal to all members of the process group so that's the way to go, but you should make sure that the parent starts a process group (or that the parent's parent starts a process group and you don't care about the parent's parent getting possibly getting a the TERM signal if it's still alive).

If you're using a shell to start the parent (or the parent's parent), then you don't have to worry about that because each command invocation in the shell does start a process group.

(There's a Linux specific feature that may be used to tell the kernel to send children processes a signal when their parent dies, but in your standard Unix, this does not take place as far as I know. Check out prctl(2) and search for DEATHSIG if you want to learn more about it).

  • So if killing the PGID is better, what would be the comparable command to pkill -TERM -P to kill the PGID instead of the PPID? – user53029 Aug 7 '15 at 15:13
  • pkill has a -g switch; with kill you put a - in front of the PGID. Read the manpages for more info. – PSkocik Aug 7 '15 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.