Subject: Re: Pipes truncating data in cygwin from main and cygwin-3_4-branch
From: キャロウ マーク via Cygwin<[email-masked]>
To: Takashi Yano <[email-masked]>
Cc: [email-masked]
Date: Tue, 15 Aug 2023 18:09:50 +0900
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>

> On Aug 15, 2023, at 15:42, Takashi Yano <[email-masked]> wrote:
> 
>> 
>>> 
>>> New pipe implementation since cygwin 3.4.x provides the pipes
>>> more similar to pipe in command prompt for non-cygwin apps.
>> 
>> What are the differences between these pipes? What changed?
> 
> Many changes. But, the change which triggers this behaviour
> is setting FILE_SYNCHRONOUS_IO_NONALERT create option.
> 
> With this option, seekg() of Microsoft library gets success
> for pipes, despite it should not I suppose.

On what create is this option specified? I have the seekg() test because on some systems you can seek on stdin when it is being redirected to read from a file, or so I read somewhere. Perhaps I should always buffer stdin on Windows to avoid this problem.

I will put some tracing in `test-pipe.c++` to see whether it is currently buffering or not.

> 
> In Linux, man page states that fseek() on pipes will fail.
> 
>>> Since your test case is compiled with cl.exe, it is non-cygwin
>>> apps.
>> 
>> When the failure first appeared the bash shell included with Git for Windows was being used to run the pipe (`bash -c "cat foo | bar”`). The shell was started by ctest which had been run from PowerShell. Is this cygwin or non-cygwin?
> 
> It depends on "bar". If bar is compiled with cl.exe or gcc/g++ in
> MSYS2 mingw environment, it is non-cygwin app.
> 
>> in https://github.com/git-for-windows/git/issues/4464#issuecomment-1671137446 the author provided minimal adaption to the reproducer to compile it with g++ and reproduced the failure on Cygwin. It looks like the failure happens for both cygwin and non-cygwin. It is probably related to the new pipe implementation you mentioned.
> 
> Is there any failure case where the pipe reader is cygwin (or MSYS2)
> binary?

We’ve only tested non-Cygwin consumers. When the author of the above GitHub issue comment was testing on Cygwin he compiled the consumer with mingw-w64 g++.

Regards

    -Mark

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple