Reputation: 24748
#!/bin/sh
echo "Running $(basename $0) $*"
function on_err {
echo $?
echo "error happened"
}
trap "on_err" 2 15
while true
do
:
done
$ kill -15 pid
gives
0
error happened
I was hoping to see
143
error happened
Upvotes: 1
Views: 169
Reputation: 1305
Do something in while loop instead spinning infinite.
while true
do
sleep 1
done
use kill -15 -PID
instead kill -15 PID
Output:
Running test.sh
0
Terminated: 15
143
Upvotes: 1