可否调用waitpid来等待其他用户的进程退出
能否调用waitpid来等待其他用户的进程退出?
waitpid函数是设计能用来做这件事情的吗?
谢谢。
------解决思路----------------------
wait,waitpid,waitid这三个系统调用只可以等待子进程的状态,不存在父子进程关系无法收到SIGCHILD信号。
见man wait
DESCRIPTION
All of these system calls are used to wait for state changes in a child of the calling process, and obtain information about the child whose state has
changed. A state change is considered to be: the child terminated; the child was stopped by a signal; or the child was resumed by a signal. In the case of
a terminated child, performing a wait allows the system to release the resources associated with the child; if a wait is not performed, then the terminated
child remains in a "zombie" state (see NOTES below).
If a child has already changed state, then these calls return immediately. Otherwise they block until either a child changes state or a signal handler
interrupts the call (assuming that system calls are not automatically restarted using the SA_RESTART flag of sigaction(2)). In the remainder of this page,
a child whose state has changed and which has not yet been waited upon by one of these system calls is termed waitable.
waitpid函数是设计能用来做这件事情的吗?
谢谢。
------解决思路----------------------
wait,waitpid,waitid这三个系统调用只可以等待子进程的状态,不存在父子进程关系无法收到SIGCHILD信号。
见man wait
DESCRIPTION
All of these system calls are used to wait for state changes in a child of the calling process, and obtain information about the child whose state has
changed. A state change is considered to be: the child terminated; the child was stopped by a signal; or the child was resumed by a signal. In the case of
a terminated child, performing a wait allows the system to release the resources associated with the child; if a wait is not performed, then the terminated
child remains in a "zombie" state (see NOTES below).
If a child has already changed state, then these calls return immediately. Otherwise they block until either a child changes state or a signal handler
interrupts the call (assuming that system calls are not automatically restarted using the SA_RESTART flag of sigaction(2)). In the remainder of this page,
a child whose state has changed and which has not yet been waited upon by one of these system calls is termed waitable.