From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 17795 invoked from network); 27 Jan 2021 10:14:27 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 27 Jan 2021 10:14:27 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1611742467; b=rSV/eZvDqzCdSjTH/izBAA6PKz+9Zcbi2IL0rIhFDLcJGpGLmMOJZ764KxN2TYOg0E+0JrkOC+ SkYCR1Bms/bcUVDHXe7C1Nngj5V5RHOJ9iZDqBIhIzg0wJF4SoNxK3ZeEVOkVs5IpSBYaNQTox 09zlApmmJbbSDhpRFxV4gEafpGE5/tF3oeyzNp9BvQpNZVx2Vzx8nG9ih/VcGwOsQmd/kAnrZj ALl48InqHWvqX2gBGoet6Y7yupnzZx0OYivF2DxxzGX3qYJxsV60/cL35Ls5AsMOiZ8EHZ8ATv Lg8A6Lt9F9Ah9/sDkHf+u8SeorO7fHRe+crpgMfaU+X6IA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (rcpt-expgw.biglobe.ne.jp) smtp.remote-ip=133.208.98.1; dmarc=none header.from=kba.biglobe.ne.jp; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1611742467; bh=BPzgMsN07W5WCseBjZbIesry+5WusvA6/DjPd5rwjJg=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:To:References:Message-ID:Content-Transfer-Encoding:Cc:Date: In-Reply-To:From:Subject:MIME-Version:Content-Type:DKIM-Signature; b=a/QeYDSeWDokVcNssunOwMBGEeY18tSpq2QVXAJW16To+AKqPfQPkShDqn+RjP3oCZiEvaGAzU hyknUsoFtWEBeqTj1+IqxTKPEH4Fc2W9v4tc2zbyIVqS3Wnn5kzL8d1MB0LB2uwRkjaV9q9k2U S2MCbK6bAM7N/Or/uKG+hiqzqymlgkSofpA0IY+Y0hLzeSTnxq/ZSCkZf3l+vakP+PVxnVQnPF K/eCibmSfP8V0WIlQGIhnEvY+7ZP58IwRoyTxgQSV1VF435Bz7pgUh+sKFD5FZrWbsvq3IUEyi U4pWaPELTPXNWHoAWM30S2vkshiSM93VuBTWibiTqaaDUg==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:To:References:Message-Id: Content-Transfer-Encoding:Cc:Date:In-Reply-To:From:Subject:Mime-Version: Content-Type:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=co1UPPqhO1Ydl0kFA45pM+FYtezjAqptl2wDRkWX7Fk=; b=doKcMsJwNQV3dbcxxQBepMXfBN obwKR4291/CyxXgYYuaXMST0h9NuW5/UWBuzJobugV5Jhta1GXFzAzUWpbivfkTwXobt4zngJPIDh erkLlne38m+AlqY1nEXhp4hZ0/4a8vzywiloYHpqIKk66vRK4BCc4HPczMObnroy4sQ/IG5wxIv2P UQ1ShU+/U2AVNio9fdMeU4eI4daTnbgDck9sMxRIARDq1xIWWOg5K7a+XiJy9fNuC2Tuc5ffkqMpZ MtJqZcRuyKvDn7QDqJ6D2A4NQUnGg0L2lMGaaiDC5sC/N7AOAYACvyuRCyXjsHAnfYtSVmDW4KMGX qkkvxwKw==; Received: from authenticated user by zero.zsh.org with local id 1l4hqC-000JKU-QD; Wed, 27 Jan 2021 10:14:24 +0000 Authentication-Results: zsh.org; iprev=pass (rcpt-expgw.biglobe.ne.jp) smtp.remote-ip=133.208.98.1; dmarc=none header.from=kba.biglobe.ne.jp; arc=none Received: from rcpt-expgw.biglobe.ne.jp ([133.208.98.1]:50368) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1l4hq0-000JBE-6r; Wed, 27 Jan 2021 10:14:14 +0000 Received: from vc-gw.biglobe.ne.jp by rcpt-expgw.biglobe.ne.jp (hngd/4514161018) with ESMTP id 10RAE5BS002678; Wed, 27 Jan 2021 19:14:05 +0900 Received: from smtp-gw.biglobe.ne.jp ([192.168.154.160]) by vc-gw.biglobe.ne.jp (shby/1011270619) with ESMTP id 10RAE58T012921; Wed, 27 Jan 2021 19:14:05 +0900 X-Biglobe-Sender: Received: from tamac1.yz.yamagata-u.ac.jp ([133.24.84.20]) by smtp-gw.biglobe.ne.jp id TZCcC0A89944; Wed, 27 Jan 2021 19:14:05 +0900 (JST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.17\)) Subject: Re: Possible ZSH bug involving piping ls to less (MSYS2 & Cygwin) From: Jun T In-Reply-To: <00ca01d6f456$656e4aa0$304adfe0$@gmail.com> Date: Wed, 27 Jan 2021 19:14:05 +0900 Cc: Alexandros Kozak Content-Transfer-Encoding: 7bit Message-Id: <541DBFB6-EEF6-406F-BF19-1AB46E468864@kba.biglobe.ne.jp> References: <00ca01d6f456$656e4aa0$304adfe0$@gmail.com> To: zsh-workers@zsh.org X-Mailer: Apple Mail (2.3445.104.17) X-Biglobe-Spnum: 29936 X-Seq: 47882 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: > 2021/01/27 11:44, agkozak@gmail.com wrote: > > I'm pretty sure it's been happening intermittently for quite a while, but I > couldn't say for sure when it started. Sorry. > > I found a discussion on GitHub of a similar problem where git was being > piped to tig: > > https://github.com/jonas/tig/issues/951 [1] This github issue suggests the problem has started in zsh-5.6, and I have confirmed that zsh-5.5.1 does not have this problem. [2] My Widows10/Cygwin (or MSYS2) is running in a virtual machine (on macOS). If I allocate only one CPU core to the virtual machine, then problem does not occur. [3] I used strace command to find the following: When ls exits, the main zsh gets SIGCHLD and calls wait_for_processes(). In this function, signals.c, line 543, it calls /* pn->pid is the pid of ls */ When the problem occurs, this returns -1 with errno==ESRCH. So the parent zsh thinks that there is no process left in the process group (leader = ls) and reclaims the control terminal. When killpg(pn->pid, 0) is called, the subshell for less has already forked, and it has already called setpgrp(0, pid_of_ls) But fork/exec in Cygwin (or MSYS2) is very slow (emulated) and, when the problem occurs, exec(less) has not yet "completed". It *seems* that killpg(pid_of_ls, 0) fails if the subshell is in the middle of exec(less). Is there anyone familiar with Cygwin/MSIS2?