Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

trap, eval and wait (was: [BUG] exec + builtin and traps)

On 2017-09-12 13:10:54 +0100, Peter Stephenson wrote:
> On Tue, 12 Sep 2017 14:02:37 +0200
> Vincent Lefevre <vincent@xxxxxxxxxx> wrote:
> > Why is "foo" (from the trap) printed before "bar", then?
> OK, so it's on the *sub* list after the command before the &&
> (wait) has executed successfully, but before the foo is executed.

I still don't understand. Actually, the real issue is that "wait"
should not have terminated successfully. Perhaps, this should be
clearer with:

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:


And after another second:


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.

Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

Messages sorted by: Reverse Date, Date, Thread, Author