-
-
Save ptrlv/c5740b176578e4cbf7a85426419fc1bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function trap_handler() { | |
echo "Caught $1, signalling pilot PID: $pilotpid" | |
kill -s $1 $pilotpid | |
wait | |
} | |
trap 'trap_handler SIGTERM' SIGTERM | |
trap 'trap_handler SIGQUIT' SIGQUIT | |
trap 'trap_handler SIGSEGV' SIGSEGV | |
trap 'trap_handler SIGXCPU' SIGXCPU | |
trap 'trap_handler SIGUSR1' SIGUSR1 | |
trap 'trap_handler SIGBUS' SIGBUS | |
sleep 30 & | |
pilotpid=$! | |
echo pilotpid: $pilotpid | |
wait $pilotpid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ps. you can test by sending a signal to the trap.sh process, not the pilotpid. Use pstree -p to get the correct pid.