From f0a2cc82478dd3c15df7350a5b052dfb97536b75 Mon Sep 17 00:00:00 2001 From: Karol Latecki Date: Wed, 12 Sep 2018 09:58:28 +0200 Subject: [PATCH] test/common: check if pid is alive before kill MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Need to check if process still exists before killing it. Otherwise if process crashed and no longer exists kill will return with "no such process" error and prevent other steps in trap from executing. Change-Id: I4402d06a4fafa09dc13fba4ef9ebeb2b2fc686bb Signed-off-by: Karol Latecki Reviewed-on: https://review.gerrithub.io/425353 Chandler-Test-Pool: SPDK Automated Test System Tested-by: SPDK CI Jenkins Reviewed-by: Paweł Niedźwiecki Reviewed-by: Shuhei Matsumoto Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- test/common/autotest_common.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/common/autotest_common.sh b/test/common/autotest_common.sh index b6269f25c..f72cb7219 100755 --- a/test/common/autotest_common.sh +++ b/test/common/autotest_common.sh @@ -338,9 +338,11 @@ function killprocess() { exit 1 fi - echo "killing process with pid $1" - kill $1 - wait $1 + if kill -0 $1; then + echo "killing process with pid $1" + kill $1 + wait $1 + fi } function iscsicleanup() {