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

[4.2/4.3] Bug with wait and trapped signals



zsh (all versions?) does not interrupt a "wait" when it receives
a signal for which a trap has been set.

For instance, consider the following script:

#!/usr/bin/env zsh
echo "PID = $$"
sleep 60 &
trap 'echo term; exit 0' TERM
wait

When I send SIGTERM to the shell process, zsh does nothing, waiting
for the child to terminate before executing the trap. POSIX says:

 2.11 Signals and Error Handling

   [...] When the shell is waiting, by means of the wait utility, for
   asynchronous commands to complete, the reception of a signal for
   which a trap has been set shall cause the wait utility to return
   immediately with an exit status >128, immediately after which the
   trap associated with that signal shall be taken.

http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_11

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / SPACES project at LORIA



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