This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: pthreads, fork+exec, and deadlocks


On Wed, Sep 10, 2003 at 11:15:07AM -0700, Roland McGrath wrote:
> > After fork(), I want to close all file descriptors, endpwent(),
> > closelog(), manage stdio/stderr/stdin etc. properly before doing the
> > exec().
> 
> Probably all these descriptors should have FD_CLOEXEC set so the right
> thing happens automatically at exec.

Yeah, w/o setting FD_CLOEXEC on each descriptor, you're in for a rough ride.
Luckily on Linux and Solaris there's a short cut: /proc/self/fd. You can
read that directory and close the descriptors. AIX has an F_CLOSEM fcntl
facility, which lets you close all descriptor above a given integer. Outside
of that, you're just S-O-L.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]