From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.dk
Subject: Re: Odd job-reporting buglet (Re: Change in suspend behavior)
Date: Fri, 11 May 2001 10:47:39 +0200 (MET DST) [thread overview]
Message-ID: <200105110847.KAA06216@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: <1010511042149.ZM27456@candle.brasslantern.com>
Bart Schaefer wrote:
> ...
>
> Change that loop just a little bit and some really strange things happen:
>
> schaefer[501] for i in bar foo; do cat & wait; done
> [2] 27451
> [2] + suspended (tty input) cat
> [1] 27452
> [1] + suspended (tty input) cat
> zsh: suspended (tty input) cat |
> zsh: running for i in bar foo; do; cat & wait; done
>
> Eh? It thinks "cat" has been piped to the for loop! Also, how did job
> number 2 get a smaller process ID than job number 1?
>
> schaefer[502] jobs -l
> [1] + 27452 suspended (tty input) cat |
> 27453 running for i in bar foo; do; cat & wait; done
> [2] - 27451 suspended (tty input) cat
Aaarrrrggghhh!
The reason is pretty clear (to some): the sub-job returns and is
stopped, so execpline() things it has to do all that super/sub-job
handling it does when the sub-job was suspended with ^Z.
One way to try to fix this is to make execpline() check if the sub-job
really was suspended because of a ^Z (SIGTSTP). And only then create a
super-job and whatnot.
The other way to try to fix this would be to check if the sub-job was
ASYNC (i.e. it had a `&' at the end), pass that information up to (the
right) execpline() and there decide to not wrap it into a super-job.
The patch below (not committed and certainly not to be committed before
we've discussed this some more) does the first for me (check for SIGTSTP).
I think both solutions have their pros and cons. Opinions?
Bye
Sven
Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.26
diff -u -r1.26 exec.c
--- Src/exec.c 2001/03/30 16:51:54 1.26
+++ Src/exec.c 2001/05/11 08:47:30
@@ -1064,11 +1064,26 @@
jn->stat & STAT_DONE &&
lastval2 & 0200)
killpg(mypgrp, lastval2 & ~0200);
+#if 0
+ /* This does the wrong thing if the sub-job was stopped
+ * for some other reason than the user hitting ^Z. In that
+ * case we don't want it to put the whole loop (or whatever)
+ * into a super-job. */
if (!list_pipe_child && !lpforked && !subsh && jobbing &&
(list_pipe || last1 || pline_level) &&
((jn->stat & STAT_STOPPED) ||
(list_pipe_job && pline_level &&
(jobtab[list_pipe_job].stat & STAT_STOPPED)))) {
+#endif
+ if (!list_pipe_child && !lpforked && !subsh && jobbing &&
+ (list_pipe || last1 || pline_level) &&
+ (((jn->stat & STAT_STOPPED) &&
+ WIFSTOPPED(jn->procs->status) &&
+ WSTOPSIG(jn->procs->status) == SIGTSTP) ||
+ (list_pipe_job && pline_level &&
+ (jobtab[list_pipe_job].stat & STAT_STOPPED) &&
+ WIFSTOPPED(jobtab[list_pipe_job].procs->status) &&
+ WSTOPSIG(jobtab[list_pipe_job].procs->status) == SIGTSTP))) {
pid_t pid;
int synch[2];
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
next prev parent reply other threads:[~2001-05-11 8:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20010510195228.018E6DCC4@mail.cise.ufl.edu>
[not found] ` <010510153513.ZM24266@candle.brasslantern.com>
2001-05-11 4:21 ` Bart Schaefer
2001-05-11 8:47 ` Sven Wischnowsky [this message]
2001-05-11 15:52 ` Bart Schaefer
2001-05-14 8:50 ` 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=200105110847.KAA06216@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--cc=zsh-workers@sunsite.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).