3

I know this sounds like a common question and I should be able to find answer in archives. Tried looking for some, but couldn't find. All the responses look very lengthy. Any 1-liner to kill a process in linux including all its children processes.

xyz
  • 8,607
  • 16
  • 66
  • 90
  • 2
    Visit [link](http://stackoverflow.com/questions/2618403/how-to-kill-all-subprocesses-of-shell), it should help. – psiphi75 Aug 28 '12 at 10:36

2 Answers2

5

If they're all in the same group, use kill and pass the negation of the group id, as in here.

Community
  • 1
  • 1
Caio Cunha
  • 23,326
  • 6
  • 78
  • 74
2
kill $PID $(pgrep -P $PID)

pgrep -P lists PIDs of all childs (not recursively)

rindeal
  • 993
  • 11
  • 16