zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-workers@zsh.org
Subject: Re: Bug in sh emulation
Date: Sat, 10 Dec 2011 19:40:22 +0000	[thread overview]
Message-ID: <20111210194022.5051f91c@pws-pc.ntlworld.com> (raw)
In-Reply-To: <111209184747.ZM5000@torch.brasslantern.com>

On Fri, 09 Dec 2011 18:47:47 -0800
Bart Schaefer <schaefer@brasslantern.com> wrote:
> It's stuck in an infinite TTOU/CONT loop because for some reason it
> wants to attachtty(), which it can't because it's not the process leader
> (the parent shell still in the foreground is).

While my minds on this, and in the knowledge that, based on past form,
only Bart is actually going to respond...

What's confusing me, possibly based on ignorance, is that I naively
expect something like the following to happen (without my
ultra-ultra-tentative patch).

- Shell forks.  This is treated pretty much like any other fork to
create a new foreground process.  If, for example, it was an editor we'd
expect the parent shell to stand back and let the editor grab the
terminal.  I don't see anything that makes the subshell a special case
here.  For example, we call addproc() to mark the newly forked process as the group leader from the main shell.

- Job control is active, so the forked shell takes over the TTY and sets
itself as the group leader.  That's the first time through the code
under discussion, in entersubsh() for the case where MONITOR is still
set.  (Have I got this wrong?  Is there actually some difference that
means the subshell, unlike any other foreground process, can't take over
the terminal?  If so, where is the logic for that?  Yet apparently the
*first* fork is happy --- it's only where we've got the pipeline with
two forks that it hangs.)

- Shell forks again.  This is a pipeline, so part of the same process
group.  I would expect this to find there is already a group leader from
the previous fork, so this process doesn't try to make itself group
leader and grab the pipeline.  Evidently this isn't happening,
however.

So what have I got wrong?  It could be anything, e.g. something in the
newly created subshell thinks it needs to create a new job, so the next
part of the pipeline doesn't know it's part of the same process group.
I'm pretty lost here.

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


  parent reply	other threads:[~2011-12-10 19:40 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-10  1:39 Ivan S. Freitas
2011-12-10  2:47 ` Bart Schaefer
2011-12-10  3:40   ` Bart Schaefer
2011-12-10 18:15     ` Peter Stephenson
2011-12-10 19:40   ` Peter Stephenson [this message]
2011-12-10 23:28     ` Peter Stephenson
2011-12-11 19:39       ` Peter Stephenson
2011-12-11 20:20         ` Peter Stephenson
2011-12-11 20:56           ` Peter Stephenson
2011-12-11 23:39             ` Bart Schaefer
2011-12-12 10:01               ` Peter Stephenson
2011-12-12 10:14                 ` Peter Stephenson
2011-12-12 15:44                 ` Bart Schaefer
2011-12-12 16:06                   ` Peter Stephenson
2011-12-12 18:10                     ` Bart Schaefer
2011-12-12 19:16                       ` Peter Stephenson
2011-12-11 22:37         ` Bart Schaefer

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=20111210194022.5051f91c@pws-pc.ntlworld.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).