Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bug in sh emulation

On Fri, 09 Dec 2011 18:47:47 -0800
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> 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,

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@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/

Messages sorted by: Reverse Date, Date, Thread, Author