From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from conssluserg-04.nifty.com (conssluserg-04.nifty.com [210.131.2.83]) by sourceware.org (Postfix) with ESMTPS id DC5AB3858001 for ; Fri, 5 Mar 2021 09:01:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DC5AB3858001 Received: from Express5800-S70 (y085178.dynamic.ppp.asahi-net.or.jp [118.243.85.178]) (authenticated) by conssluserg-04.nifty.com with ESMTP id 12591G3p016410; Fri, 5 Mar 2021 18:01:16 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-04.nifty.com 12591G3p016410 X-Nifty-SrcIP: [118.243.85.178] Date: Fri, 5 Mar 2021 18:01:16 +0900 From: Takashi Yano To: cygwin@cygwin.com Cc: Nitro Vent Subject: Re: Issue: Reading from stdin in Cywin64 Terminal (first noticed with Git Bash) with a .Net framework application hangs after some time Message-Id: <20210305180116.88f4952b95a2e6ca454b00d3@nifty.ne.jp> In-Reply-To: References: X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: cygwin@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Mar 2021 09:01:57 -0000 On Wed, 3 Mar 2021 16:11:30 +0100 Nitro Vent wrote: > I have two .Net console applications targeting .Net Framework 4.7.2, > "produce.exe" and "consume.exe" with their respective sources > > using System;using System.Threading; > namespace Produce > { > class Program > { > static void Main(string[] args) > { > Thread.Sleep(100); > Console.WriteLine("Hello World."); > } > } > } > > and > > using System; > namespace Consume > { > class Program > { > static void Main(string[] args) > { > var input = Console.In.ReadToEnd(); > Console.WriteLine(input); > } > } > } > > Running > > $ ./produce.exe | ./consume.exe > > in Cygwin Terminal I expect the output to be > > Hello World. > > But there is no output and the second process, consume.exe, hangs at > ReadToEnd(). > This was verified by looking at the running processes with ps aux when > running the consume.exe in the background as well as by attaching the > Visual Studio debugger. > > Piping produce.exe into cat works correctly. > Piping some more content into consume.exe also fails (e.g. find * /usr | > consume) > Executing the same command in Windows Command works correctly. > > Notice that piping into consume.exe works if there is no delay in the > producer. I looked into this problem and found it seems that the problem is due to the pipe mode. Cygwin pipe is set FILE_FLAG_OVERLAPPED and PIPE_TYPE_MESSAGE (by default). According to my test, this test case works only if the pipe between produce.exe and consume.exe is PIPE_TYPE_BYTE and not FILE_FLAG_OVERLAPPED set. I am not sure how the issue can be fixed. -- Takashi Yano