Bug 840782 - waitpid returns EINVAL when WNOWAIT is used
waitpid returns EINVAL when WNOWAIT is used
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: kernel (Show other bugs)
17
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Kernel Maintainer List
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-07-17 04:05 EDT by Michal Hlavinka
Modified: 2013-01-15 11:30 EST (History)
9 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-01-15 11:30:28 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


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

  None (edit)
Description Michal Hlavinka 2012-07-17 04:05:37 EDT
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 12:07:19 EDT
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 15:27:06 EDT
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 11:30:28 EST
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.