Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在制作一个 shell 脚本来杀死应用程序;但是我不能杀死像 Xcode 这样具有多个进程的应用程序,因为当我杀死已经在运行的进程时,新进程似乎会取代它们的位置,也许有一个父进程调用其他进程或其他东西,是否有解决方法?
ps -o ppid -p <childpid>将报告 PPID 列(父 PID)
ps -o ppid -p <childpid>
将结果传送tail -1到以捕获结果:
tail -1
$ ps -o ppid 12345 | tail -1
尝试杀死整个进程组:
kill -9 -<pid>
注意 pid 前的“-”