zsh-workers
 help / color / mirror / code / Atom feed
From: Jun T <takimoto-j@kba.biglobe.ne.jp>
To: zsh-workers@zsh.org
Cc: Alexandros Kozak <agkozak@gmail.com>
Subject: Re: Possible ZSH bug involving piping ls to less (MSYS2 & Cygwin)
Date: Wed, 27 Jan 2021 19:14:05 +0900	[thread overview]
Message-ID: <541DBFB6-EEF6-406F-BF19-1AB46E468864@kba.biglobe.ne.jp> (raw)
In-Reply-To: <00ca01d6f456$656e4aa0$304adfe0$@gmail.com>


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


  reply	other threads:[~2021-01-27 10:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-27  2:44 agkozak
2021-01-27 10:14 ` Jun T [this message]
2021-01-28 10:42   ` Jun T
  -- strict thread matches above, loose matches on Subject: below --
2021-01-18 19:08 agkozak
2021-01-26  1:49 ` Jun T
2022-09-13  8:49 ` Jun T

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=541DBFB6-EEF6-406F-BF19-1AB46E468864@kba.biglobe.ne.jp \
    --to=takimoto-j@kba.biglobe.ne.jp \
    --cc=agkozak@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).