fcntl with O_APPEND fails to force append mode on stderr for native Windows programs
Corinna Vinschen
corinna-cygwin@cygwin.com
Sun Feb 10 09:32:00 GMT 2019
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20190210/f8b6c277/attachment.sig>
More information about the Cygwin
mailing list