Skip to content

Instantly share code, notes, and snippets.

@mikesmullin
Created June 21, 2014 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mikesmullin/b6e91e2102163e8486bc to your computer and use it in GitHub Desktop.
Save mikesmullin/b6e91e2102163e8486bc to your computer and use it in GitHub Desktop.
Bash Process Loop
#!/bin/bash
# Process Loop
# Author: Mike Smullin <mike@smullindesign.com>
# License: MIT
# Usage:
#
# ./loop node --debug app.js
#
# Ctrl+C Restarts
# Ctrl+\ Quits
#
ctrl_c() {
echo -en "\n\n*** Restarting ***\n\n"
}
ctrl_backslash() {
echo -en "\n\n*** Killing ***\n\n"
exit 0
}
# trap keyboard interrupt (control-c)
trap ctrl_c SIGINT
trap ctrl_backslash SIGQUIT
# the loop
reset; while true; do $*; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment