2

For some reason, I have to call waitpid twice on the same child process:

Calling the waitpid the first time and there are no errors:

waitpid(pid, &status, WUNTRACED);

The second time:

waitpid(pid, &status, WNOHANG|WUNTRACED);

An error occurred: "No child process". Is there anything wrong with my code?

Update:

If the child process have already exited after or before my first calling of waitpid, which means the parent process has reaped this child process, the second calling of waitpid then causes errors. Is this correct?

4

1 回答 1

4

会不会是孩子在第二次waitpid()通话之前就终止了?AFAIR,waitpid()等待子进程终止(或其他状态更改)。

于 2013-10-08T14:06:12.180 回答