From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail231.csoft.net (mail231.csoft.net [96.47.74.235]) by sourceware.org (Postfix) with ESMTPS id 0C25A3857404 for ; Mon, 21 Mar 2022 18:46:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0C25A3857404 Received: from mail231.csoft.net (localhost [127.0.0.1]) by mail231.csoft.net (Postfix) with ESMTP id 4DA50CBC1 for ; Mon, 21 Mar 2022 14:45:57 -0400 (EDT) Received: from mail231 (mail231 [96.47.74.235]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) (Authenticated sender: jeremyd) by mail231.csoft.net (Postfix) with ESMTPSA id 48E23CBBB for ; Mon, 21 Mar 2022 14:45:57 -0400 (EDT) Date: Mon, 21 Mar 2022 11:45:57 -0700 (PDT) From: Jeremy Drake X-X-Sender: jeremyd@resin.csoft.net To: cygwin@cygwin.com Subject: pipe hang issue when running as SYSTEM Message-ID: User-Agent: Alpine 2.21 (BSO 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Mon, 21 Mar 2022 18:46:02 -0000 This issue was reported to MSYS2 as a hang when trying to build libxml2 in a Windows docker container. Another user was able to come up with a simple reproducer and a reasonable theory as to why it happens. The msys2 issue is https://github.com/msys2/msys2-runtime/issues/77, and I will quote the reproducer and analysis here: I am having the same issue when building mingw. I managed to reduce the issue to the following shell script: #!/bin/sh seq 1 99999 > big_file eval '$(eval cmd.exe /c "type big_file" | : )' When running as a normal user this completes immediately, but when run as a system service it hangs forever. The issue appears to be that when running under the SYSTEM account, the third sh process holds open the read end of the pipe. Since cmd has too much output to write all at once, it waits until the pipe's buffer has room to write more, but since sh isn't actually reading from the pipe, this hangs forever. When running as a normal user the read end of the pipe is not kept open, and so cmd.exe gets an error when attempting to write and exits immediately. My suspicion is that this is caused by f79a461 (which keeps the read end of the pipe open) and b531d6b (which changes the behavior depending on whether or not the program is running as a service).