Skip to content

Instantly share code, notes, and snippets.

@ThomasSevestre
Last active April 1, 2022 21:47
Show Gist options
  • Select an option

  • Save ThomasSevestre/2c52301c805541b4ed4bf3c585505a61 to your computer and use it in GitHub Desktop.

Select an option

Save ThomasSevestre/2c52301c805541b4ed4bf3c585505a61 to your computer and use it in GitHub Desktop.
#!/bin/bash
# usage :
# sudo killtree pid
killtree() {
local _pid=$1
kill -STOP ${_pid}
for _child in $(ps -o pid --no-headers --ppid ${_pid}); do
killtree ${_child}
done
kill -KILL ${_pid}
}
if [ $# -ne 1 ]; then
echo "Usage: $(basename $0) <pid>"
exit 1
fi
killtree $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment