kill_pid_recursively() { local pid=$1 local parent_pid=$2 if [ ! -z ${pid} ]; then for child_pid in `pgrep -P ${pid}`; do kill_pid_recursively ${child_pid} ${pid} done echo "kill PID: ${pid}, its PPID is ${parent_pid}" kill -9 ${pid} fi }
kill_pid_recursively ${SOME_PID} 'nothing'
|