This is the mail archive of the
mailing list for the Cygwin project.
File descriptor lossage during thread termination
- From: "Ivan Warren" <ivan at vmfacility dot fr>
- To: <cygwin at cygwin dot com>
- Date: Wed, 6 Oct 2004 19:14:12 +0200
- Subject: File descriptor lossage during thread termination
I am encountering the following problem :
I have a multithreaded application. Some of the inter-thread communication
is performed by pipes (pipe()).. One thread issues a 'select' and the other
one writes to it..
However, I am encountering a situation when another thread (not necessaraly
involved in the above communication) under the same process, terminates
(through return), some (or all) of the pipe (and possibly other) file
descriptors become unavailable. This leads to, such symptoms as 'select'
giving an errno of 9 (EBADF : Bad File Descriptor).
I am currently running 1.5.11 (release).
The following test case demonstrates the issue. This is invoked with 0 or n
arguments. With n arguments, a new thread is created and then terminates
after 4 seconds. When this happens, select receives rc<0 and the program
terminates (via exit()).
Also, this same testcase does not exhibit that particular behaviour on other
posix systems (tried on linux anyways).
The application that is being affected by this issue doesn't seem to have
any problem running under 1.5.10 (haven't tried this particular test case
under 1.5.10 though).
void *thr(void *);
void *thr1(void *);
int main(int ac,char **av)
printf("Read %d chars from pipe\n",rc);
printf("Read %d chars from kbd\n",rc);
void *thr(void *x)
void *thr1(void *x)
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html