Last active
August 29, 2015 14:18
-
-
Save ptbrowne/2c13241c0d5bdce1a312 to your computer and use it in GitHub Desktop.
sigrestart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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