This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


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

fcntl(F_SETFD) on a file or socket handle


Hello.

Just want report a serious bug in Cygwin.

Many applications use this construct in their code:
fcntl(fd, F_SETFD, 1); /* set close on exec flag */

fcntl(fd) below is a replacement for the above construct,
fd - file/socket descriptor, resulted from an open() or a socket() call.

Some symptoms:

1. If an fd is a socket and fcntl(fd) is called right after the connect(fd) call,
connection will get broken.

2. If an fd is transferred via a pipe end and fcntl(fd) is called right after
write(pipe, &fd, sizeof(fd)) call, the another pipe end will receive an invalid
fd handle.

If in the both cases above add sleep(1) before fcntl(fd), then all works without
a failure.

I didn't investigate it further, and probably will not have time in the near
future to do so. Sorry.

--
Dmitry.


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


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