fcntl with O_APPEND fails to force append mode on stderr for native Windows programs
Corinna Vinschen
corinna-cygwin@cygwin.com
Sat Feb 9 14:51:00 GMT 2019
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.
Thanks,
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/20190209/5ee8aaec/attachment.sig>
More information about the Cygwin
mailing list