X-Recipient: archive-cygwin@delorie.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8AF90385E837
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
	s=default; t=1647888428;
	bh=j11rhzRS0Ylod8J+uHxnemgEIlUt9uRs5pdWBCr4DYA=;
	h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:
	 List-Help:List-Subscribe:From:Reply-To:From;
	b=c+5lFI9EguwTmDY9ZX6YyE+h1qwVOUdjMkAZDpTioLXI5ZyuwBowm5CtZ5pr1eQb7
	 keLIDDuASOfz4t5RMv7+FDXjkwnjQv7E0QQxloKm8jWvWhY06vrT9w7llM+s2LSpl7
	 v7LOuzv5mhsMlufT67ghsc6vfHoGGnCNeHz7iAJI=
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0C25A3857404
Date: Mon, 21 Mar 2022 11:45:57 -0700 (PDT)
X-X-Sender: jeremyd@resin.csoft.net
To: cygwin@cygwin.com
Subject: pipe hang issue when running as SYSTEM
Message-ID: <alpine.BSO.2.21.2203211141320.56460@resin.csoft.net>
User-Agent: Alpine 2.21 (BSO 202 2017-01-01)
MIME-Version: 1.0
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
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-request@cygwin.com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=subscribe>
From: Jeremy Drake via Cygwin <cygwin@cygwin.com>
Reply-To: Jeremy Drake <cygwin@jdrake.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie.com@cygwin.com>

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).

-- 
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
