Bug 840782 - waitpid returns EINVAL when WNOWAIT is used
Summary: waitpid returns EINVAL when WNOWAIT is used
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: kernel
Version: 17
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Kernel Maintainer List
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-07-17 08:05 UTC by Michal Hlavinka
Modified: 2013-01-15 16:30 UTC (History)
9 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2013-01-15 16:30:28 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
reproducer (777 bytes, text/plain)
2012-07-17 08:05 UTC, Michal Hlavinka
no flags Details

Description Michal Hlavinka 2012-07-17 08:05:37 UTC
Created attachment 598585 [details]
reproducer

Description of problem:
When used with WNOWAIT, waitpid returns EINVAL error. This breaks ksh buildtime tests.

Version-Release number of selected component (if applicable):
glibc-2.15-48.fc17

How reproducible:
always

Steps to Reproduce:
1. gcc reproducer.c -o reproducer
2. ./reproducer
3.
  
Actual results:
./reproducer 
WNOWAIT waitpid returns -1,     status=32767, errno=22 : Invalid argument
WNOHANG waitpid returns <PID>,  status=0, errno=0 : Success
0       waitpid returns -1,     status=0, errno=10 : No child processes

Expected results:
./reproducer 
WNOWAIT waitpid returns <PID>,  status=0, errno=0 : Success
WNOHANG waitpid returns <PID>,  status=0, errno=0 : Success
0       waitpid returns -1,     status=0, errno=10 : No child processes

Additional info:

Comment 1 Jeff Law 2012-08-08 16:07:19 UTC
This is reall a kernel issue -- glibc merely provides an interface into the kernel for system calls such as wait, waitpid, etc.  It doesn't munge, interpret or otherwise care about the return value or the options for this family of system calls.

Comment 2 Dave Jones 2012-08-08 19:27:06 UTC
curious.

As the vfork won't return until after the child has exited, I would have expected the waitpid's to be returning ECHILD in all cases, as the pid wouldn't be valid at that point.

I recommend bringing this up on linux-kernel.

Comment 3 Josh Boyer 2013-01-15 16:30:28 UTC
As far as I can see, waitpid (and wait4) don't allow WNOWAIT.  That is probably why it is returning -ENIVAL, because that is not a valid option for that system call.

The options that are allowed for waitpid are WNOHANG, WUNTRACED, and WCONTINUED as documented in the man page.  There are Linux specific options that can be used if the children were created with clone, and those are __WCLONE, __WALL, and __WNOTHREAD.

The waitid call does accept WNOWAIT, but that is not the same thing as waitpid.

I'm not seeing how this is a bug.


Note You need to log in before you can comment on or make changes to this bug.