仅杀死父进程,而不是 bash 中的子进程和父进程

Killing parent process only, not both child and parent in bash

我正在尝试按名称终止进程。它应该先杀死子进程,然后再杀死父进程,但我只会杀死父进程。请需要帮助。编辑:已解决

请这样试:

PID=$(ps -aef | grep `whoami` | grep $argument | grep -v grep | grep -v $$ | awk '{print }'
for x in ${PID[@]}; do
  CPID=$(ps -aef | grep `whoami` | grep $PID | grep -v grep | grep -v $$ | awk '{print }'
  for y in ${CPID[@]}; do 
    kill $y
  done
  kill $x
done