aboutsummaryrefslogtreecommitdiff
path: root/cbt
diff options
context:
space:
mode:
authorChristopher Vogt <oss.nsp@cvogt.org>2017-06-15 22:38:53 -0400
committerChristopher Vogt <oss.nsp@cvogt.org>2017-06-15 22:43:59 -0400
commit09051773461b98d374d1b46dd0a2caa57768ab30 (patch)
treed67c88d10906647c7fd56229e6e56121a9107744 /cbt
parentb5194aab6f1f57aff6e4538acaf91245fdf15039 (diff)
downloadcbt-09051773461b98d374d1b46dd0a2caa57768ab30.tar.gz
cbt-09051773461b98d374d1b46dd0a2caa57768ab30.tar.bz2
cbt-09051773461b98d374d1b46dd0a2caa57768ab30.zip
add sbt-resolver like restart feature
Diffstat (limited to 'cbt')
-rwxr-xr-xcbt16
1 files changed, 16 insertions, 0 deletions
diff --git a/cbt b/cbt
index 4a5b736..e2014ec 100755
--- a/cbt
+++ b/cbt
@@ -290,6 +290,7 @@ stage1 () {
USER_PRESSED_CTRL_C=130
CBT_LOOP_FILE="$CWD/target/.cbt-loop.tmp"
+CBT_KILL_FILE="$CWD/target/.cbt-kill.tmp"
if [ $loop -eq 0 ]; then
which fswatch >/dev/null 2>/dev/null
export fswatch_installed=$?
@@ -305,6 +306,9 @@ while true; do
if [ -f "$CBT_LOOP_FILE" ]; then
rm "$CBT_LOOP_FILE"
fi
+ if [ -f "$CBT_KILL_FILE" ]; then
+ rm "$CBT_KILL_FILE"
+ fi
stage1 "$@"
if [ ! $loop -eq 0 ] || [ $exitCode -eq $USER_PRESSED_CTRL_C ]; then
log "not looping, exiting" "$@"
@@ -316,6 +320,10 @@ while true; do
files=
if [ -f "$CBT_LOOP_FILE" ]; then
files=($(sort "$CBT_LOOP_FILE"))
+ fi
+ pids=
+ if [ -f "$CBT_KILL_FILE" ]; then
+ pids=($(cat "$CBT_KILL_FILE")) # FIXME: should we uniq here?
#rm "$CBT_LOOP_FILE"
fi
echo ""
@@ -326,6 +334,14 @@ while true; do
fi
done
fswatch --one-event "${files[@]}"
+ for pid in "${pids[@]}"; do
+ if [ $pid == "" ]; then
+ echo "warning: empty pid found in pid kill list" 1>&2
+ else
+ log "killing process $pid"
+ kill -KILL $pid
+ fi
+ done
fi
done