Not sure about how using supervisord
, but with pkill
you can use the -P
option to kill from a parent process down to all the children. Here's the process trees (starting from my running ssh daemon).
$ pstree -a -p 1792
sshd,1792
├─sshd,27150
│ └─sshd,27153
│ └─zsh,27154
│ └─test.sh,27325 ./test.sh
│ └─cat,27326
└─sshd,27182
└─sshd,27184
└─zsh,27185
└─pstree,27357 -a -p 1792
In one session I have a script test.sh
with pid 27325, and in the other I'm running the command pstree -a -p 1792
(because sshd
had pid 1792)
And after I run pkill -TERM -P 27325
:
$ pstree -a -p 1792
sshd,1792
├─sshd,27150
│ └─sshd,27153
│ └─zsh,27154
└─sshd,27182
└─sshd,27184
└─zsh,27185
└─pstree,27387 -a -p 1792
This answer was essentially rephrased from the this other answer on stackoverflow: https://stackoverflow.com/a/392155/263969