From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: Re: pws-22: killing the ZSH loops problem
Date: Fri, 18 Jun 1999 10:55:09 +0200 (MET DST) [thread overview]
Message-ID: <199906180855.KAA12796@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Sven Wischnowsky's message of Thu, 17 Jun 1999 11:23:16 +0200 (MET DST)
I wrote:
> Bart Schaefer wrote:
>
> > 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.
>
> I think, this is the way to go. I'll have a look at it, but probably not
> before the weekend.
I was to hasty to agree with this...
Unless I'm missing something obvious, we can't simply execute
processes in a loop (or other shell construct) in the same pgrp as the
shell. Sure, this would give us the SIGINT, but it would also give us
the SIGSTOP -- suspending the shell.
So the patch below at least makes loops suspendable as a whole, even
if they are not part of a pipeline (it was strange that we could do it
for `foo | while ...' but not for `while ...'). For the ^C'ing of such
loops I don't see a good solution any more -- other than this: with the
patch you can ^Z the loop, fg it and then you can ^C it if the next
external command has been started, because then the sub-shell created
when the loop was suspended gets the SIGINT, too, and terminates.
(Btw. `foo | while ...' can be ^C'ed because we have the `foo' to find
that out. This means that we could make normal loops be ^C'able by
forking of a sub-shell for every loop and let the sub-shell do
nothing. Then ^C would SIGINT the sub-shell and the parent shell would
be notified about this -- but this is really ugly isn't it? Or should
we? But that would be an extra fork on every shell construct...)
And another `btw.': comparison with bash shows that it has the same
problem ^C'ing such commands in loops and behaves like zsh. But it
can't even correctly stop such loops.
Bye
Sven
diff -u oos/exec.c Src/exec.c
--- oos/exec.c Fri Jun 18 08:50:07 1999
+++ Src/exec.c Fri Jun 18 08:50:23 1999
@@ -919,7 +919,7 @@
}
for (; !nowait;) {
- if (list_pipe_child) {
+ if (list_pipe_child || pline_level) {
jn->stat |= STAT_NOPRINT;
makerunning(jn);
}
@@ -930,8 +930,8 @@
jn->stat & STAT_DONE &&
lastval2 & 0200)
killpg(mypgrp, lastval2 & ~0200);
- if ((list_pipe || last1) && !list_pipe_child &&
- jn->stat & STAT_STOPPED) {
+ if ((list_pipe || last1 || pline_level) &&
+ !list_pipe_child && jn->stat & STAT_STOPPED) {
pid_t pid;
int synch[2];
@@ -961,7 +961,8 @@
jobtab[list_pipe_job].stat |= STAT_SUPERJOB;
jn->stat |= STAT_SUBJOB | STAT_NOPRINT;
jn->other = pid;
- killpg(jobtab[list_pipe_job].gleader, SIGSTOP);
+ if (list_pipe || last1)
+ killpg(jobtab[list_pipe_job].gleader, SIGSTOP);
break;
}
else {
@@ -988,7 +989,8 @@
jn->stat |= STAT_NOPRINT;
killjb(jobtab + pj, lastval & ~0200);
}
- if (list_pipe_child || (list_pipe && (jn->stat & STAT_DONE)))
+ if (list_pipe_child || ((list_pipe || pline_level) &&
+ (jn->stat & STAT_DONE)))
deletejob(jn);
thisjob = pj;
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
next reply other threads:[~1999-06-18 8:55 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-06-18 8:55 Sven Wischnowsky [this message]
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
-- strict thread matches above, loose matches on Subject: below --
1999-06-21 11:29 Sven Wischnowsky
1999-06-17 9:23 Sven Wischnowsky
1999-06-16 9:09 Andrej Borsenkow
1999-06-16 8:43 Andrej Borsenkow
1999-06-15 16:45 Andrej Borsenkow
1999-06-16 15:14 ` Peter Stephenson
1999-06-16 17:16 ` 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=199906180855.KAA12796@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--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).