diff --git a/btest-bg-run-helper b/btest-bg-run-helper index 8d84107b..4ca9ebea 100755 --- a/btest-bg-run-helper +++ b/btest-bg-run-helper @@ -2,9 +2,23 @@ # # Internal helper for btest-bg-run. -trap "kill 0" 0 +cleanup () + { + if [ ! -e .exitcode ]; then + echo 15 >.exitcode + kill 0 &>/dev/null -eval $@ & + if [ ! -z "$pid" ]; then + kill -0 $pid &>/dev/null && kill $pid + sleep 1 + kill -0 $pid &>/dev/null && kill -9 $pid && echo 9 >.exitcode + fi + fi + } + +trap "cleanup" EXIT + +eval "$@ &" pid=$! echo $$ >.pid