From f3b3c5bd84a9cfba7008b51343b9ee5c33609f0b Mon Sep 17 00:00:00 2001 From: Michal Berger Date: Mon, 27 Dec 2021 20:33:38 +0100 Subject: [PATCH] test/common: Don't exit from within the killprocess() This breaks the flow of EXIT traps that use this function together with errexit. Consider: set -e trap 'killprocess $pid_not_found; nvmftestfini' EXIT ... if killprocess() suddenly exits the remaining parts of the trap won't be executed. Also, if the process is not found, allow killprocess() to return success - if it's gone then the main goal of the function is already achieved. If the process terminated abruptly errexit should pick that up regardless. Signed-off-by: Michal Berger Change-Id: I93c00c2a2da5457affb2ed2b5bf0ebae9c4bf291 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10853 Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins Reviewed-by: Tomasz Zawadzki Reviewed-by: Jim Harris --- test/common/autotest_common.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/common/autotest_common.sh b/test/common/autotest_common.sh index 77cd6de47..110e44781 100755 --- a/test/common/autotest_common.sh +++ b/test/common/autotest_common.sh @@ -813,7 +813,7 @@ function make_filesystem() { function killprocess() { # $1 = process pid if [ -z "$1" ]; then - exit 1 + return 1 fi if kill -0 $1; then @@ -840,7 +840,6 @@ function killprocess() { else # the process is not there anymore echo "Process with pid $1 is not found" - exit 1 fi }