This is the mail archive of the cygwin 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]
Other format: [Raw text]

Re: fork() + file descriptor bug in 1.7.27(0.271/5/3) 2013-12-09 11:54


On Jan 15 23:42, tednolan@bellsouth.net wrote:
> >> FWIW, FreeBSD, Linux and Solaris all compile and run the test program
> >> with the behavoir I expect..
> >
> >Just for completeness:  I can test on Linux, but not on FreeBSD and
> >Solaris.  Does the testcase also work as expected on both of them,
> >after you added fclose to the child?  On Linux it does.
> >
> >
> >Thanks,
> >Corinna
> >
> 
> Well, it appears I spoke too soon about Solaris.  I saw that it terminated
> rather than running forever, and assumed it was working correctly.
> That turns out not to be the case: For 3 lines in the input file, it somehow
> gets up to 8 processes before terminating.
> 
> Here's what I can say per OS:
> 
> FreeBSD 4.9
> FreeBSD 8.1
> FreeBSD 9.1
> 
> 	Original test case works.
> 	Test case with fclose() works
> 	Test case with _exit() instead of exit() works
> 
> Solaris 9:
> 
> 	Original test case fails (but terminates)
> 	Test case with fclose() fails
> 	Test case with _exit() instead of exit() works
> 
> Cygwin:
> 	Original test case fails (never terminates)
> 	Test case with fclose() fails
> 	Test case with _exit() instead of exit() works
> 
> Gentoo Linux:
> 	Original test case works
> 	Test case with fclose() -- don't have access right now
> 	Test case with _exit() instead of exit() -- don't have access rght now

Can you change your testcase another bit, please?  Enable your
`ftell' printf, but rather than printing the result of ftell,
print the result of lseek:

  fprintf(stderr, "(%s) (%s) %d %ld\n", infile,
        outfile, i, lseek(fileno(fp), 0, SEEK_CUR));

I would be curious what happens on Solaris here.

> So, as per other posters, exit() is wrong and should be _exit().  I accept
> that, and will fix it, but it still seems to be that the Linux and FreeBSD
> behavior is better here.  If the spec allows "spooky action at a distance",
> that's not the same as encouraging it..

Well, not quite.  In theory, Linux is our role model for this kind of
behaviour, so I would opt for changing that to follow Linux.  It's an
easy patch, but it's a bit dangerous, because the code in question is
shared with newlib, so a change affects a lot of other targets as well.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

Attachment: pgp27zIYRr1az.pgp
Description: PGP signature


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