This is the mail archive of the cygwin-patches@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]

Re: warnings on handle close


On Tue, Oct 23, 2001 at 12:24:45AM +0400, egor duda wrote:
>Hi!
>
>  this program complains about error on handle close.
>
>#include <sys/fcntl.h>
>
>int main ()
>{
>  int f = open ("/dev/tty", O_RDWR);
>  fcntl (f, F_SETFD, 1);
>  close (f);
>}
>
>the reason is that we duplicate handle when fcntl is called, but it's
>old handle value that's left registered in handle list.
>patch attached.

I'm surprised that this is necessary.  I thought that the same handle was
reused in this situation.  However, even if that was the case, I shouldn't
have relied on that undocumented fact.

I think that I can come up with a slightly less intrusive change than this
one, involving an additional argument to setclexec_pid.

I'll check something in shortly.

Thanks for tracking this down.  These kind of problems can be very
frustrating and difficult to unearth.

cgf


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