Last active
April 1, 2022 21:47
-
-
Save ThomasSevestre/2c52301c805541b4ed4bf3c585505a61 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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