Skip to content

Instantly share code, notes, and snippets.

@asergeyev
Created March 3, 2014 13:26
Show Gist options
  • Save asergeyev/9324881 to your computer and use it in GitHub Desktop.
Save asergeyev/9324881 to your computer and use it in GitHub Desktop.
#!/bin/sh
# this will fire even when sleep is working (when assuming bash)
ok(){
echo "TRAP"
exit 2
}
trap "ok" SIGINT
echo "Start sleeping a minute, send me a signal using"
echo "kill -s SIGINT $$"
sleep 60 & wait
echo "Normal quit"
#!/bin/sh
# this will only fire when sleep is done (when assuming bash)
ok(){
echo "TRAP"
exit 2
}
trap "ok" SIGINT
echo "Start sleeping a minute, send me a signal using"
echo "kill -s SIGINT $$"
sleep 60
echo "Normal quit"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment