質問

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?

役に立ちましたか?

解決

Could it be that the child terminated prior to the second waitpid() call? AFAIR, waitpid() waits for child process termination (or other change of state).

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top