Bug 840782

Summary: waitpid returns EINVAL when WNOWAIT is used
Product: [Fedora] Fedora Reporter: Michal Hlavinka <mhlavink>
Component: kernelAssignee: Kernel Maintainer List <kernel-maint>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 17CC: gansalmon, itamar, jakub, jonathan, kernel-maint, law, madhu.chinakonda, pfrankli, schwab
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-01-15 16:30:28 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
reproducer none

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.