zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@ibmth.df.unipi.it>
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:14:19 +0200	[thread overview]
Message-ID: <9906161514.AA26937@ibmth.df.unipi.it> (raw)
In-Reply-To: ""Andrej Borsenkow""'s message of "Tue, 15 Jun 1999 20:45:04 DFT." <001901beb74e$6b1dcdc0$21c9ca95@mow.siemens.ru>

"Andrej Borsenkow" wrote:
> bor@itsrm2:~%> while true
> while> do
> while> echo $((i++))
> while> sh -c "read line"
> while> done
> 0
> ^C
> 1
> ^C
> 2

I've formed a hypothesis based on different versions of ksh.

On some versions, the `sh -c' goes into a different process group: here, I
get the same problem as zsh.  On others, the process group of the sh is the
same as that of the ksh: then the loop exits cleanly.

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.

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.

I haven't quite understood why a zsh in the loop works properly (i.e. the
loop exits cleanly when interrupted), but it seems to be nothing to do with
process groups: the `zsh -c' is exiting with the correct status
(i.e. WIFSIGNALED(...) returns true so the parent shell know what
happened).  Looks like we got something right.  Arguably we can blame the
problem on all those shells which don't do this :-).  (Next we find it's
only because of a bug that zsh works this way...)

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


  reply	other threads:[~1999-06-16 15:43 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 [this message]
1999-06-16 17:16   ` Bart Schaefer
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=9906161514.AA26937@ibmth.df.unipi.it \
    --to=pws@ibmth.df.unipi.it \
    --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).