Skip to content

Instantly share code, notes, and snippets.

@danielribeiro
Last active December 25, 2015 01:29
Show Gist options
  • Save danielribeiro/6895259 to your computer and use it in GitHub Desktop.
Save danielribeiro/6895259 to your computer and use it in GitHub Desktop.
self killing shell
#!/bin/bash
# trap "kill -- -$BASHPID" SIGINT SIGTERM EXIT
trap 'exit 42' SIGINT SIGQUIT SIGTERM
function sayit() {
while [[ 1 ]]
do echo oi
sleep 1
done
}
sayit &
echo it is running
sleep 1
echo i m almost done
kill 0
# kill -HUP -$$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment