Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: trap, eval and wait (was: [BUG] exec + builtin and traps)
On Tue, 12 Sep 2017 16:21:45 +0200
Vincent Lefevre <vincent@xxxxxxxxxx> wrote:
> trap 'echo foo' USR1
> ( sleep 1; kill -USR1 $$; sleep 1; echo child ) &
> eval "wait && echo bar"
> echo OK
> sleep 2
> ------------------------------------------------------------
>
> After 1 second, the following is printed:
>
> foo
> bar
> OK
>
> And after another second:
>
> child
>
> So, this means that the "wait" has ended due to the USR1 signal, not
> by a process termination. But then, the fact that "wait" terminates
> with the exit status 0 does not seem to be correct.
There's a funny here (yes, I know, we're all amazed) --- wait is
actually waiting for two jobs. One of them has the flags
STAT_BUILTIN|STAT_CURSH|STAT_NOPRINT, and it turns out this is the
second one it waits for and it returns status 0. The return status from
wait only reflects the last job waited for --- I believe that much is
standard.
Quite possibly any of the above flags should mean wait ignores the job,
but I've taken STAT_NOPRINT as the most logical to test here as it
basically means "user is not interested in this".
pws
diff --git a/Src/jobs.c b/Src/jobs.c
index 66dfb5a..226e7cf 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -2217,7 +2217,8 @@ bin_fg(char *name, char **argv, Options ops, int func)
return 0;
} else { /* Must be BIN_WAIT, so wait for all jobs */
for (job = 0; job <= maxjob; job++)
- if (job != thisjob && jobtab[job].stat)
+ if (job != thisjob && jobtab[job].stat &&
+ !(jobtab[job].stat & STAT_NOPRINT))
retval = zwaitjob(job, 1);
unqueue_signals();
return retval;
Messages sorted by:
Reverse Date,
Date,
Thread,
Author