Fehler #614 » trap_test2.sh
| 1 |
#!/bin/bash
|
|---|---|
| 2 |
|
| 3 |
# Our USR1 signal handler
|
| 4 |
function usr1_trap(){ |
| 5 |
printf 'Here is the PID: %d\nExiting right-now!\n' $$ |
| 6 |
# exit
|
| 7 |
}
|
| 8 |
|
| 9 |
# Register USR1 signal handler
|
| 10 |
trap usr1_trap USR1
|
| 11 |
|
| 12 |
printf 'Run this to stop me:\nkill -USR1 %d\n' $$ |
| 13 |
|
| 14 |
# Wait in background, not consuming CPU
|
| 15 |
while :; do |
| 16 |
sleep 9223372036854775807 & # int max (2^63 - 1) |
| 17 |
wait $! |
| 18 |
done
|