当前位置: 技术问答>linux和unix
有谁来解释下waitpid函数中 pid的值为-1和0的区别
来源: 互联网 发布时间:2016-04-06
本文导语: man中解释如下: -1 which means to wait for any child process; this is the same behaviour which wait exhibits. 0 which means to wait for any child process whose process ...
man中解释如下:
-1 which means to wait for any child process; this is the same
behaviour which wait exhibits.
0 which means to wait for any child process whose process group ID
is equal to that of the calling process.
我的理解是,在为0时,能捕捉到不同用户组运行该程序时的子进程???貌似不行,我做过试验,将另一个用户的进程杀掉。。
-1 which means to wait for any child process; this is the same
behaviour which wait exhibits.
0 which means to wait for any child process whose process group ID
is equal to that of the calling process.
我的理解是,在为0时,能捕捉到不同用户组运行该程序时的子进程???貌似不行,我做过试验,将另一个用户的进程杀掉。。
|
表9-3 waitpid参数pid取值情况表
参数值 函数waitpid功能
pid>0 等待进程标识号为pid的子进程结束
pid=0 等待进程组标识等于父进程进程组标识的子进程结束
pid=-1 等待任意子进程结束
pid
参数值 函数waitpid功能
pid>0 等待进程标识号为pid的子进程结束
pid=0 等待进程组标识等于父进程进程组标识的子进程结束
pid=-1 等待任意子进程结束
pid