Skip to content

Instantly share code, notes, and snippets.

@srkiNZ84
Created April 13, 2015 22:27
Show Gist options
  • Save srkiNZ84/dcd5b3c7e2c1d1920bd7 to your computer and use it in GitHub Desktop.
Save srkiNZ84/dcd5b3c7e2c1d1920bd7 to your computer and use it in GitHub Desktop.
Simple script to test/demo simple signal handling in bash
#!/bin/bash
function sigusr1 {
echo "Received SIGUSR1."
STOP_EXECUTION=1
echo "Stopping execution after current item"
}
trap 'sigusr1' USR1
STOP_EXECUTION=0
while ((!STOP_EXECUTION)); do
echo "Running..."
sleep 5
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment