Re: fcntl with O_APPEND fails to force append mode on stderr for native Windows programs
- Date: Sat, 9 Feb 2019 15:33:28 +0000
- From: Tom Honermann <thomas.honermann@xxxxxxxxxxxx>
- Subject: Re: fcntl with O_APPEND fails to force append mode on stderr for native Windows programs
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:
>> [ 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:
> 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!
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple