标题: linux wait 等待进程状态改变,这里的状态包含哪些? [打印本页] 作者: socay2 时间: 2013-12-15 19:26 标题: linux 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).
这是源自man wait的解释,这里解释说进程的终止、停止、和唤醒都叫做状态的改变。可是通过kill 发送 SIGCONT 信号给子进程时,wait还是处于阻塞状态! 请问是不是wait是要等到子进程结束了才解除阻塞呢?作者: 井蛙夏虫 时间: 2013-12-15 21:46 回复 1# socay2
文档继续向下看
The wait() system call suspends execution of the calling process until one of its children terminates. The call wait(&status) is equivalent to:
waitpid(-1, &status, 0);
复制代码
wait只能是子进程终止。如果要子进程继续和暂停都可以,要用waitpid
The waitpid() system call suspends execution of the calling process until a child specified by pid argument has changed state. By default, waitpid() waits only for terminated children, but this
behavior is modifiable via the options argument, as described below.
复制代码
The value of options is an OR of zero or more of the following constants:
WNOHANG return immediately if no child has exited.
WUNTRACED also return if a child has stopped (but not traced via ptrace(2)). Status for traced children which have stopped is provided even if this option is not specified.
WCONTINUED (since Linux 2.6.10)
also return if a stopped child has been resumed by delivery of SIGCONT.