From 201a5d4aeae3bc43927aeb2b4fed6043d51cdf93 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Mon, 27 Jan 2014 10:05:24 -0800 Subject: [PATCH] run-*d.sh: fix --shell support when interrupted The --shell option is supposed to enter an interactive shell after the jobd or taskd executable exits. But if jobd or taskd was interrupted with a signal (e.g. SIGINT via ^C) then the script itself would also be interrupted and the --shell option would not take effect. Switch to /bin/bash instead of /bin/sh and set a trap to make sure the --shell option remains effective when the jobd or taskd executable is interrupted via a signal. --- toolbox/run-jobd.sh | 5 +++-- toolbox/run-taskd.sh | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/toolbox/run-jobd.sh b/toolbox/run-jobd.sh index 98644d9..3b1054e 100755 --- a/toolbox/run-jobd.sh +++ b/toolbox/run-jobd.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash cd "$HOME" @@ -6,7 +6,8 @@ DEFAULTOPTS="-q -P --load-triggers 12,6 -d 300" if [ "$1" = "--shell" ]; then shift + trap 'exec "$SHELL" -l -i' EXIT /usr/bin/nice -n 18 perl -I@basedir@/jobd @basedir@/jobd/jobd.pl $DEFAULTOPTS "$@" - exec "$SHELL" -l -i + exit fi exec /usr/bin/nice -n 18 perl -I@basedir@/jobd @basedir@/jobd/jobd.pl $DEFAULTOPTS "$@" diff --git a/toolbox/run-taskd.sh b/toolbox/run-taskd.sh index 165a44c..8f70575 100755 --- a/toolbox/run-taskd.sh +++ b/toolbox/run-taskd.sh @@ -1,10 +1,11 @@ -#!/bin/sh +#!/bin/bash cd "$HOME" if [ "$1" = "--shell" ]; then shift + trap 'exec "$SHELL" -l -i' EXIT perl -I@basedir@/taskd @basedir@/taskd/taskd.pl "$@" - exec "$SHELL" -l -i + exit fi exec perl -I@basedir@/taskd @basedir@/taskd/taskd.pl "$@" -- 2.11.4.GIT