Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 196298 - sys-libs/glibc-2.5-r4 - bad return code of wait() when no waitable childs
Summary: sys-libs/glibc-2.5-r4 - bad return code of wait() when no waitable childs
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: AMD64 Linux
: High normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-10-18 16:10 UTC by mehrunes
Modified: 2007-10-22 04:22 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mehrunes 2007-10-18 16:10:37 UTC
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
Comment 1 René 'Necoro' Neumann 2007-10-18 21:19:48 UTC
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 :)
Comment 2 SpanKY gentoo-dev 2007-10-19 06:38:14 UTC
ive got nothing to add ... René covered it all already ;)
Comment 3 mehrunes 2007-10-22 04:17:57 UTC
 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 ===============
Comment 4 mehrunes 2007-10-22 04:22:12 UTC
ah yes, the ERRORS section describes the code set in errno, i misunderstood it, sorry