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: fcntl with O_APPEND fails to force append mode on stderr for native Windows programs


On Feb  9 15:33, Tom Honermann wrote:
> On 2/9/2019 9:51 AM, Corinna Vinschen wrote:
> > On Feb  8 22:25, Tom Honermann wrote:
> >> The following program demonstrates the problem.
> >> [...]
> >> Here is where things go bananas.  If the program is run with stdout
> >> initially redirected to a pipe, then the stderr output from the native
> >> Windows program ends up overwriting the stdout output from the two
> >> calls to echo:
> >>
> >> $ ./test | cat
> >> $ cat out
> >> The syntax of this command is:
> >>
> >> NET
> >>     [ ACCOUNTS | COMPUTER | CONFIG | CONTINUE | FILE | GROUP | HELP |
> >>       HELPMSG | LOCALGROUP | PAUSE | SESSION | SHARE | START |
> >>       STATISTICS | STOP | TIME | USE | USER | VIEW ]
> >>
> >> Note that the lines containing "first" and "second" are now absent in
> >> the file.
> > Thanks for the testcase.  I tracked this down to a bug when calling
> > native (non-Cygwin) apps.  If the descriptor is in O_APPEND mode, we
> > have to set the file offset to EOF before calling native apps.  However,
> > this only worked reliably for the first descriptor in O_APPEND mode, but
> > only by chance for subsequent descriptors in O_APPEND mode.  Your
> > example code with the extra pipe to `cat' triggered the misbehaviour.
> >
> > I fixed that in git master:
> > https://sourceware.org/git/?p=newlib-cygwin.git;a=commitdiff;h=0be0b8f0335e
> >
> > This will be in the 3.0.0 release.
> >
> > I just uploaded new developer snapshots to https://cygwin.com/snapshots/
> > You only need to replace the Cygwin DLL for testing.  Please give it a try.
> 
> Thank you, Corinna!  This does appear to fix the problem.  I verified
> the snapshot with the original test case and the one above and both work
> as expected now.  We'll do some more extensive testing and report back
> if we find any further issues.  You are awesome!

Thanks for testing.  I'll upload another 3.0.0 test release early next week
and then I hope the release can be done a few days later.


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer

Attachment: signature.asc
Description: PGP signature


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