zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: "ZSH workers mailing list" <zsh-workers@sunsite.auc.dk>
Subject: Re: pws-22: killing the ZSH loops problem
Date: Wed, 16 Jun 1999 17:16:01 +0000	[thread overview]
Message-ID: <990616171601.ZM1681@candle.brasslantern.com> (raw)
In-Reply-To: <9906161514.AA26937@ibmth.df.unipi.it>

On Jun 16,  5:14pm, Peter Stephenson wrote:
} Subject: Re: pws-22: killing the ZSH loops problem
}
} "Andrej Borsenkow" wrote:
} > bor@itsrm2:~%> while true
} > while> do
} > while> echo $((i++))
} > while> sh -c "read line"
} > while> done
} > 0
} > ^C
} > 1
} > ^C
} > 2
} 
} So there are three cases (1) no job control, like sh, (2) job control and
} the sh in the while loop goes into a different pgrp, (3) job control but
} the sh in the while loop stays in the pgrp of the controlling shell.  Cases
} (1) and (3) exit cleanly, because the shell itself gets the ^C; case (2),
} which is what zsh is doing, doesn't because it doesn't.

Yes, I believe this is correct.  It's related to this comment in jobs.c:
    /* When MONITOR is set, the foreground process runs in a different *
     * process group from the shell, so the shell will not receive     *
     * terminal signals, therefore we we pretend that the shell got    *
     * the signal too.                                                 */

If the foreground job catches INT and doesn't exit with the proper status,
zsh can't tell anything other than that it exited -- just as Andrej found
by experiment.

} So maybe zsh should not set a new process group for foreground processes
} run within shell structures.  Sven, any ideas about doing this?  It might
} clash with job control for such processes, which are currently handled by
} forking the shell and setting its pgrp to that of the other jobs; this
} wouldn't be possible any more, so we're going to have to live with
} something not working.

One possibility is to not permit job control of individual external jobs
run within a shell construct; that is, force ^Z to stop the entire shell
loop and restart it.  As has been mentioned before, this is easy in other
shells because they typically fork off the tails of pipelines whereas zsh
always forks off the heads -- but some of the new list_pipe code that was
added recently may give us the necessary hooks to manage it.  Given that,
we can stop using new pgrps for subjobs of a shell construct, and then
zsh can get the terminal signals directly again.

Unfortunately this might require shoveling around some bits of context
information that aren't presently available, in order to prevent the
execution code from creating the new process group.  I haven't looked.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


  reply	other threads:[~1999-06-16 17:16 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-06-15 16:45 Andrej Borsenkow
1999-06-16 15:14 ` Peter Stephenson
1999-06-16 17:16   ` Bart Schaefer [this message]
1999-06-16  8:43 Andrej Borsenkow
1999-06-16  9:09 Andrej Borsenkow
1999-06-17  9:23 Sven Wischnowsky
1999-06-18  8:55 Sven Wischnowsky
1999-06-18 15:33 ` Andrej Borsenkow
1999-06-18 16:44   ` Bart Schaefer
1999-06-21  7:08     ` Andrej Borsenkow
1999-06-21 15:55       ` Bart Schaefer
1999-06-21 16:14         ` Andrej Borsenkow
1999-06-21 11:29 Sven Wischnowsky

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=990616171601.ZM1681@candle.brasslantern.com \
    --to=schaefer@candle.brasslantern.com \
    --cc=zsh-workers@sunsite.auc.dk \
    /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).