进程可以等待不是子进程之一的 PID 吗?
Can a process wait for a PID that is not one of the children?
我想知道我们是否可以使用系统调用
waitpid()
等待孙子的 pid
waitpid()
是 POSIX。
The wait() and waitpid() functions shall obtain status information (see Status Information) pertaining to one of the caller's child processes.
所以你的问题的答案是 "No",至少从标准的角度来看是这样。
这不一定要阻止实现提供对标准的扩展。
来自 POSIX 还有:
Nothing in this volume of POSIX.1-2008 prevents an implementation from providing extensions that permit a process to get status from a grandchild or any other process, but a process that does not use such extensions must be guaranteed to see status from only its direct children.
我想知道我们是否可以使用系统调用
waitpid()
等待孙子的 pid
waitpid()
是 POSIX。
The wait() and waitpid() functions shall obtain status information (see Status Information) pertaining to one of the caller's child processes.
所以你的问题的答案是 "No",至少从标准的角度来看是这样。
这不一定要阻止实现提供对标准的扩展。
来自 POSIX 还有:
Nothing in this volume of POSIX.1-2008 prevents an implementation from providing extensions that permit a process to get status from a grandchild or any other process, but a process that does not use such extensions must be guaranteed to see status from only its direct children.