How to kill all subprocesses of shell?

pkill -P $$

will fit (just kills it’s own descendants)

EDIT: I got a downvote, don’t know why. Anyway here is the help of -P

   -P, --parent ppid,...
          Only match processes whose parent process ID is listed.

and $$ is the process id of the script itself

Leave a Comment