Linux kill 进程组

在Linux中,除了进程外,还有一个进程组的概念:

一个进程所创建的子进程,都会被包含到一个进程组中。

所以,我们可以用进程组杀死某个进程及其fork出的所有子进程。

1、跟进进程pid查看某个进程所属的进程组

ps -o pgid 19843
 PGID
  977

2、kill 某个进程组的所有进程

kill -- -977

注意上面的--和空格和-都不能少哦!

 

 

2 thoughts on “Linux kill 进程组

Leave a Reply to muxueqz Cancel reply

Your email address will not be published. Required fields are marked *