Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Possible ZSH bug involving piping ls to less (MSYS2 & Cygwin)
- X-seq: zsh-workers 47882
- From: Jun T <takimoto-j@xxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Cc: Alexandros Kozak <agkozak@xxxxxxxxx>
- Subject: Re: Possible ZSH bug involving piping ls to less (MSYS2 & Cygwin)
- Date: Wed, 27 Jan 2021 19:14:05 +0900
- Archived-at: <https://zsh.org/workers/47882>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-workers/2021-01/541DBFB6-EEF6-406F-BF19-1AB46E468864%40kba.biglobe.ne.jp>
- In-reply-to: <00ca01d6f456$656e4aa0$304adfe0$@gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <00ca01d6f456$656e4aa0$304adfe0$@gmail.com>
> 2021/01/27 11:44, agkozak@xxxxxxxxx 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?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author