X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 59FA43857033 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1614934918; bh=HHrDC2O5ZPLBe/ePOwnh/nmQSA7DvFwFfVYNOWrdnPc=; h=Date:To:Subject:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=IdsqB0WIWJz/Io4ErrHKgpNkZ5kOqJCa0jQV8Ksm/IMoWUZaBDTgr7C4sgSu2RbtM ntAiZIU2q4wXbLaa7Qsd1HS3TTx2S41maIK055lhgg60GJUzLcY5EclwtVY+dLhWzd tm9yPihCKO6leDXzcqk8Jd0B64T6ijqR/fIFKUbo= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DC5AB3858001 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 To: cygwin AT cygwin DOT com 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 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 AT cygwin DOT 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: , From: Takashi Yano via Cygwin Reply-To: Takashi Yano Cc: Nitro Vent Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: cygwin-bounces AT cygwin DOT com Sender: "Cygwin" 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 -- 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