waitpid man page ( sys-apps/man-pages-2.64 ) says that wait(...) func shall return ECHILD when there's no child to wait for errno.h defines ECHILD to be 0xA and wait(0) implemented by /lib64/libc.so.6 ( sys-libs/glibc-2.5-r4 ) returns -1 when no-more-child Reproducible: Always Steps to Reproduce: ============= start of prog #include <stdio.h> #include <errno.h> #include <sys/types.h> #include <sys/wait.h> int main() { pid_t r=wait(0); printf("r,ECHILD=%x,%x\n",r,ECHILD); } ============= end of prog compile with gcc and run on gentoo/amd64 //i did not test this on platforms other than amd64 Actual Results: r,ECHILD=ffffffff,a Expected Results: the printed values ought to be equal
man 2 wait: (man-pages-2.65): "RETURN VALUE wait(): on success, returns the process ID of the terminated child; on error, -1 is returned. [...] Each of these calls sets errno to an appropriate value in the case of an error. ERRORS ECHILD (for wait()) The calling process does not have any unwaited-for children." Perhaps you just misunderstood it :) (and on "man 3p wait" I can't find your quote either) -> it won't return the error, but return -1 and set the global errno :)
ive got nothing to add ... René covered it all already ;)
René 'Necoro' Neumann and others: use man2html on `man 2 wait`, open result with a web browser then search for ECHILD. It is in ERRORS section closer to the end of page. ==================== man page piece starts here ===================== ERRORS ECHILD (for wait()) The calling process does not have any unwaited-for children. ECHILD (for waitpid() or waitid()) The process specified by pid (waitpid()) or idtype and id (waitid()) does not exist or is not a child of the calling process. (This can happen for one's own child if the action for SIGCHLD is set to SIG_IGN. See also the Linux Notes section about threads.) EINTR WNOHANG was not set and an unblocked signal or a SIGCHLD was caught. EINVAL The options argument was invalid. =============================== man page piece ends here ===============
ah yes, the ERRORS section describes the code set in errno, i misunderstood it, sorry