zsh-workers
 help / color / mirror / code / Atom feed
From: Stephane Chazelas <stephane@chazelas.org>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Rudi C <rudiwillalwaysloveyou@gmail.com>,
	"zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Re: [Bug] Unexpected process suspension
Date: Wed, 13 May 2020 07:29:02 +0100	[thread overview]
Message-ID: <20200513062902.gf6e22g4sqni75x4@chazelas.org> (raw)
In-Reply-To: <CAH+w=7Zb_zaasw4NSVRt4kznqWEyr17TFqf6N5=7yhBTefH5Dw@mail.gmail.com>

2020-05-12 10:38:38 -0700, Bart Schaefer:
> On Tue, May 12, 2020 at 12:03 AM Rudi C <rudiwillalwaysloveyou@gmail.com> wrote:
> >
> > mdoc-test () {
> >
> >     sleep 0 | sleep 0
> >     cat}
> >
> > echo start |VISUAL=vim command vipe|mdoc-test
> >
> > # zsh: suspended (tty output)
> 
> Putting an interactive command in the middle of a pipeline is
> generally not going to work.  Vim in particular is pretty aggressive
> about trying to grab a terminal, which will result in processes
> getting SIGTT* because they don't have foreground control of the
> terminal they're trying to use.
[...]

The thing is vim *should* be in the foreground, all the
processes started in pipeline should be in the same process
group which should be in foreground (so it gets
SIGINT/SIGQUIT/SIGTSTP upon ^C/^\/^Z, so it can read the
terminal, etc) but under some circumstances, zsh fails to put
some processes in that group, which is a bug.

$ </proc/self/stat awk '{print $5, $8}' >&2
127235 127235
$ </proc/self/stat awk '{print $5, $8; system("exec sleep 1")}'  >&2 | ps -o pid,pgid,comm
131569 131569
    PID    PGID COMMAND
 124948  124948 zsh
 131569  131569 awk
 131570  131569 ps
 131571  131569 sleep
$ </proc/self/stat awk '{print $5, $8}' >&2 | { :; }
127410 127410
$ </proc/self/stat awk '{print $5, $8}' >&2 | { : | :; }
127496 124948

In that latter case, awk is in a different process group
(127496) from the terminal foreground process group (124948
which here is the process group of the main shell process!).

-- 
Stephane

  reply	other threads:[~2020-05-13  6:29 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-12  7:02 Rudi C
2020-05-12 11:48 ` Daniel Shahaf
2020-05-12 11:53   ` Roman Perepelitsa
2020-05-12 11:57     ` Daniel Shahaf
2020-05-12 12:05       ` Roman Perepelitsa
2020-05-12 13:31     ` Stephane Chazelas
2020-05-12 17:38 ` Bart Schaefer
2020-05-13  6:29   ` Stephane Chazelas [this message]
2020-05-20 22:32     ` Rudi C
2020-05-21  3:33       ` A bug tracker (was: Re: [Bug] Unexpected process suspension) Daniel Shahaf
2020-05-21  4:44         ` Bart Schaefer
2020-05-21 13:39         ` Oliver Kiddle
2020-05-21 16:46           ` Daniel Shahaf

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=20200513062902.gf6e22g4sqni75x4@chazelas.org \
    --to=stephane@chazelas.org \
    --cc=rudiwillalwaysloveyou@gmail.com \
    --cc=schaefer@brasslantern.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).