+ -
当前位置:首页 → 问答吧 → 父进程调用wait函数究竟对子进程做了什么?

父进程调用wait函数究竟对子进程做了什么?

时间:2011-07-13

来源:互联网

父进程创建的子进程退出后,如果父进程不调用wait函数回收子进程的结束信息,子进程就会变成僵尸进程。
那么父进程调用wait函数究竟对子进程做了什么呢?希望高手帮忙解答,谢了

作者: heartgoon2010   发布时间: 2011-07-13

Linux man: 
wait for state changes in a child of the calling process, and obtain information about the child whose state has changed.
等待子进程的状态变化,并获取相关信息。

The wait() system call suspends execution of the calling process until one of its children terminates.
父进程调用wait时,并没有对子进程做什么,它仅表示我关心子进程的状态变迁,并将自己切入到睡眠状态(暂停自己)。当子进程退出时,父进程被唤醒,通过wait返回值,父进程可以知道子进程退出原因。

作者: csusuntao   发布时间: 2011-07-13