site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com On 04 May 2011, at 06:13, Anatol Pomozov wrote: if (waitpid(pid, &status, 0) < 0) { perror("waitpid); printf("fail waitpid = %d\n", pid); } The code looks pretty much typical, everything seems fine. But the code fails on macosx - waitpid() returns ECHILD error. waitpid() thinks that there is no any child with such pid. Hmm, why? int res; do { res = waitpid(pid, &status, 0); } while ((res < 0) && (errno == EINTR)); if (res < 0) { perror("waitpid); printf("fail waitpid = %d\n", pid); } Jonas _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... Although probably unrelated to the error you are getting, the above code is not safe. You must use something like this instead: There are many low level libc routines that directly map to syscalls and which can return EINTR. In every such case you must use a loop like the above, or at least correctly deal with the special case of EINTR. This email sent to site_archiver@lists.apple.com