Skip to content

Instantly share code, notes, and snippets.

@ptbrowne
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ptbrowne/2c13241c0d5bdce1a312 to your computer and use it in GitHub Desktop.
Save ptbrowne/2c13241c0d5bdce1a312 to your computer and use it in GitHub Desktop.
sigrestart
#! /bin/bash
# Usage:
# ./sigrestart 11 gulp watch
# Here if by any chance the command `gulp watch` is killed
# via the signal 11 (SIGSEGV), it will be restarted
# Since gulp has the bad habit of dying with SIGSEGV, it is
# very useful
signal=$1
shift
cmd="$@"
echo "Restarts \"$cmd\" after signal $signal"
$cmd
while [[ $? == $(( 128 + signal )) ]]; do
echo "Restarting after signal $signal"
$cmd
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment