From a0c1f220c7c6ce28e198536dc6d1c960544fb6f1 Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Tue, 21 Oct 2014 20:05:45 -0700 Subject: [PATCH] tests: use kill -0 to check process existence When killing a daemon, instead of using kill -9 to check the process was terminated, use kill -0. Should the pid of the process be reused immediately after, it would be wrong to kill the new process. Worst case scenario the kill_daemon function returns before the process is confirmed to be killed but this is not treated as an error and is unlikely to cause any problem. Signed-off-by: Loic Dachary --- src/test/mon/mon-test-helpers.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/test/mon/mon-test-helpers.sh b/src/test/mon/mon-test-helpers.sh index 9d54bef22461a..ca25dd52db295 100644 --- a/src/test/mon/mon-test-helpers.sh +++ b/src/test/mon/mon-test-helpers.sh @@ -68,8 +68,10 @@ function kill_daemons() { local dir=$1 for pidfile in $(find $dir | grep '\.pid') ; do pid=$(cat $pidfile) + signal=9 for try in 0 1 1 1 2 3 ; do - kill -9 $pid 2> /dev/null || break + kill -$signal $pid 2> /dev/null || break + signal=0 sleep $try done done -- 2.39.5