Skip to content

Instantly share code, notes, and snippets.

@shakemno
Last active October 8, 2017 22:49
Show Gist options
  • Save shakemno/4353e66848d6892f8140066c6d16aa8e to your computer and use it in GitHub Desktop.
Save shakemno/4353e66848d6892f8140066c6d16aa8e to your computer and use it in GitHub Desktop.
gracefully ctrl-c shell bg_task
#!/bin/sh
echo "starting background workflow..."
trap 'trap - SIGINT SIGTERM EXIT; $(kill $BGPID; exit 255)' SIGINT SIGTERM EXIT
eval 'gulp workflow &'
BGPID=$!
wait $BGPID
echo "\workflow stopped..."
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment