4

I can't find any documentation that explains my observations in sufficiently enough terms. After I run the below code, I perform a kill -SIGINT $my_pid from a different shell. I will correctly see #### received trap 2 the first two times. However, the wait command gets interrupted on each signal. Why?

#!/bin/bash

for s in {0..64}
do
    trap "echo '#### received trap $s'" $s
done

./code &
pid=$!
my_pid=$$

wait $pid
wait $pid
Amtrix
  • 143
  • 3

1 Answers1

2

3.7.6 Signals

When Bash is waiting for an asynchronous command via the wait builtin, the reception of a signal for which a trap has been set will cause the wait builtin to return immediately with an exit status greater than 128, immediately after which the trap is executed.