[uClibc 0000668]: opendir should not set FD_CLOEXEC

bugs at busybox.net bugs at busybox.net
Sat Feb 4 02:58:26 UTC 2006


A NOTE has been added to this issue. 
====================================================================== 
http://busybox.net/bugs/view.php?id=668 
====================================================================== 
Reported By:                rfelker
Assigned To:                uClibc
====================================================================== 
Project:                    uClibc
Issue ID:                   668
Category:                   Standards Compliance
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     assigned
====================================================================== 
Date Submitted:             01-30-2006 19:02 PST
Last Modified:              02-03-2006 18:58 PST
====================================================================== 
Summary:                    opendir should not set FD_CLOEXEC
Description: 
uClibc opendir sets FD_CLOEXEC. This contradicts POSIX which says
either the parent or child may continue using the directory handle,
just not both.

====================================================================== 

---------------------------------------------------------------------- 
 vapier - 02-03-06 18:32  
---------------------------------------------------------------------- 
glibc uses FD_CLOEXEC and it was added to uClibc due to POSIX conformance

http://www.opengroup.org/onlinepubs/009695399/functions/exec.html
exec() has this to say:
Directory streams open in the calling process image shall be closed in the
new process image.

http://www.opengroup.org/onlinepubs/009695399/functions/opendir.html
opendir() has this to say:
Based on historical implementations, the rules about file descriptors
apply to directory streams as well. However, this volume of IEEE Std
1003.1-2001 does not mandate that the directory stream be implemented
using file descriptors. The description of closedir() clarifies that if a
file descriptor is used for the directory stream, it is mandatory that
closedir() deallocate the file descriptor. When a file descriptor is used
to implement the directory stream, it behaves as if the FD_CLOEXEC had
been set for the file descriptor.

so, since our opendir() utilizes file descriptors in the backend, it
sounds like using the FD_CLOEXEC on the file descriptor is the correct
behavior 

---------------------------------------------------------------------- 
 rfelker - 02-03-06 18:58  
---------------------------------------------------------------------- 
OK, then this is a bug in POSIX. See:
http://www.opengroup.org/onlinepubs/009695399/functions/rewinddir.html
which reads:
"After a call to the fork() function, either the parent or child (but not
both) may continue processing the directory stream using readdir(),
rewinddir(), or [XSI] [Option Start] seekdir(). [Option End] If both the
parent and child processes use these functions, the result is undefined."

Bleh. 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
01-30-06 19:02  rfelker        New Issue                                    
01-30-06 19:02  rfelker        Status                   new => assigned     
01-30-06 19:02  rfelker        Assigned To               => uClibc          
02-03-06 18:32  vapier         Note Added: 0001034                          
02-03-06 18:58  rfelker        Note Added: 0001035                          
======================================================================




More information about the uClibc-cvs mailing list