diff options
author | Huang Ying <ying.huang@intel.com> | 2009-06-15 10:47:15 +0800 |
---|---|---|
committer | Huang Ying <ying.huang@intel.com> | 2009-06-15 10:47:15 +0800 |
commit | 7a5be0d034cf35aa236f78f471dc2097ffb9cdbc (patch) | |
tree | 175f1ab16db777f0ae4a126b8ef9d434cfc10e57 | |
parent | bc159f568024529d7b2f05aba1e24cc19670965e (diff) | |
download | mce-test-7a5be0d034cf35aa236f78f471dc2097ffb9cdbc.tar.gz |
Fix background testing signal processing
Start background testing in its own process group, so all processes
in background testing process group can be killed with:
kill -TERM -$pgrp
-rw-r--r-- | lib/functions.sh | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/functions.sh b/lib/functions.sh index e2bfd00..a5efdde 100644 --- a/lib/functions.sh +++ b/lib/functions.sh @@ -58,17 +58,19 @@ random_sleep() start_background() { if [ -n "$BACKGROUND" ]; then - eval "$BACKGROUND" "&>$WDIR/background_log &" || \ + pid_background=$(bash -i -c "$BACKGROUND &>$WDIR/background_log & echo \$!") + if ! ps -p $pid_background > /dev/null; then die "Failed to start background testing: $BACKGROUND" - pid_background=$! + fi fi } stop_background() { if [ -n "$pid_background" ]; then - kill -TERM -$pid_background || true - kill $pid_background || true + if ! kill -TERM -$pid_background &> /dev/null; then + kill $pid_background || true + fi fi } |