zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-workers@zsh.org
Subject: Re: problem with 'ls | less' shell function
Date: Thu, 20 Oct 2022 17:26:40 +0100 (BST)	[thread overview]
Message-ID: <1094839952.3286480.1666283200511@mail.virginmedia.com> (raw)
In-Reply-To: <CAH+w=7Y7X4AvdzxU1sdHUyT6oLR7zcW8qXoQEHsm6ubW=9kUqw@mail.gmail.com>


> On 20/10/2022 01:10 Bart Schaefer <schaefer@brasslantern.com> wrote:
> 
>  
> On Wed, Oct 19, 2022 at 1:28 AM <zsugabubus@national.shitposting.agency> wrote:
> >
> > I think what happens is that zsh fails to correctly set the foreground
> > process group in `fg`. `less` is not in the foreground pgrp that's why
> > it immediately gets suspended by SIGTTIN after it receives SIGCONT.
> 
> First sentence partly wrong, second sentence right.
> 
> When a shell function is suspended with ^Z, the parent shell forks
> again to create a process for the shell function, but doesn't change
> the process group of the pipeline.  When "fg" brings the shell
> function process back, that process is made group leader, but it then
> needs to reset the group leader again to the pid of its own foreground
> job, which it does not ... or, conversely, upon suspend the parent
> shell needs to avoid changing the group leader of the new process.
> 
> At this point I'm not sure which of those needs to happen or where.
> It's all in or around the call to addproc() at exec.c line 1734.

I'd be quite surprised if you didn't need to be looking at
this comment at line 1872.  This isn't necessarily the same thing
but must surely be related...

			/*
			 * At this point, we used to attach this process
			 * to the process group of list_pipe_job (the
			 * new superjob) any time that was still available.
			 * That caused problems in at least two
			 * cases because this forked shell was then
			 * suspended with the right hand side of the
			 * pipeline, and the SIGSTOP below suspended
			 * it a second time when it was continued.
			 *
			 * It's therefore not clear entirely why you'd ever
			 * do anything other than the following, but no
			 * doubt we'll find out...
			 */

pws


  reply	other threads:[~2022-10-20 16:27 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-17  9:17 Thomas Klausner
2022-10-17 14:50 ` Mikael Magnusson
2022-10-17 15:36   ` Thomas Klausner
2022-10-19  8:26     ` zsugabubus
2022-10-19 10:04       ` Jun T
2022-10-19 13:36         ` Jun. T
2022-10-20  0:10       ` Bart Schaefer
2022-10-20 16:26         ` Peter Stephenson [this message]
2022-10-21  5:45       ` Jun T
2022-10-21  7:40         ` Jun T
2022-10-21 21:22           ` Bart Schaefer
2022-10-21 21:24             ` Bart Schaefer
2022-10-22 23:22               ` Bart Schaefer
2022-10-22 23:43                 ` Bart Schaefer
2022-11-03 23:10                   ` Bart Schaefer
2022-11-04  6:09                     ` [PATCH] " Bart Schaefer
2022-11-04 15:10                       ` [PATCH] " Jun T
2022-11-05  0:09                         ` Bart Schaefer
2022-11-06 19:12                           ` Bart Schaefer
2022-11-07  8:43                             ` Jun T
2022-11-07 19:33                               ` Bart Schaefer
2022-11-07 19:44                                 ` Roman Perepelitsa
2022-11-08  0:46                                   ` Bart Schaefer
2022-11-08  0:44                                 ` Bart Schaefer
2022-11-08  5:03                                   ` Bart Schaefer
2022-11-09  5:03                                     ` Bart Schaefer
2022-10-19  9:33 ` Jun T
2022-10-19 10:01   ` 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=1094839952.3286480.1666283200511@mail.virginmedia.com \
    --to=p.w.stephenson@ntlworld.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).