From e7b3063f7ec06fdb547515c24fd956ed1af74e0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Budai?= Date: Fri, 26 Mar 2021 07:43:31 +0100 Subject: [PATCH] test: properly kill journalctl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sudo journalctl -af -n 1 -u "${WORKER_UNIT}" & WORKER_JOURNAL_PID=$! In this snippet, WORKER_JOURNAL_PID is set to the PID of the sudo process. Sudo doesn't propagate any signals - therefore the child process of sudo (journalctl in this case) isn't killed when a signal is sent to the parent. Use pkill -P instead which kills all processes where sudo is the parent. Signed-off-by: Ondřej Budai --- test/cases/aws.sh | 2 +- test/cases/ostree-ng.sh | 2 +- test/cases/ostree.sh | 2 +- test/cases/vmware.sh | 2 +- tools/libvirt_test.sh | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/cases/aws.sh b/test/cases/aws.sh index e4bed8cd8..1aad19c95 100755 --- a/test/cases/aws.sh +++ b/test/cases/aws.sh @@ -180,7 +180,7 @@ $AWS_CMD ec2 describe-images \ AMI_IMAGE_ID=$(jq -r '.Images[].ImageId' "$AMI_DATA") # Stop watching the worker journal. -sudo kill ${WORKER_JOURNAL_PID} +sudo pkill -P ${WORKER_JOURNAL_PID} # NOTE(mhayden): Getting TagSpecifications to play along with bash's # parsing of curly braces and square brackets is nuts, so we just write some diff --git a/test/cases/ostree-ng.sh b/test/cases/ostree-ng.sh index 783cbb4dc..e059a6343 100755 --- a/test/cases/ostree-ng.sh +++ b/test/cases/ostree-ng.sh @@ -151,7 +151,7 @@ build_image() { fi # Stop watching the worker journal. - sudo kill ${WORKER_JOURNAL_PID} + sudo pkill -P ${WORKER_JOURNAL_PID} } # Wait for the ssh server up to be. diff --git a/test/cases/ostree.sh b/test/cases/ostree.sh index fd1a275fd..f3514812c 100755 --- a/test/cases/ostree.sh +++ b/test/cases/ostree.sh @@ -190,7 +190,7 @@ build_image() { fi # Stop watching the worker journal. - sudo kill ${WORKER_JOURNAL_PID} + sudo pkill -P ${WORKER_JOURNAL_PID} } # Wait for the ssh server up to be. diff --git a/test/cases/vmware.sh b/test/cases/vmware.sh index 76f56411d..a6fa5b368 100755 --- a/test/cases/vmware.sh +++ b/test/cases/vmware.sh @@ -163,7 +163,7 @@ if [[ $COMPOSE_STATUS != FINISHED ]]; then fi # Stop watching the worker journal. -sudo kill ${WORKER_JOURNAL_PID} +sudo pkill -P ${WORKER_JOURNAL_PID} greenprint "👷🏻 Building VM in vSphere" $GOVC_CMD vm.create -u "${GOVMOMI_USERNAME}":"${GOVMOMI_PASSWORD}"@"${GOVMOMI_URL}" \ diff --git a/tools/libvirt_test.sh b/tools/libvirt_test.sh index 2e91da321..9572c3ac9 100755 --- a/tools/libvirt_test.sh +++ b/tools/libvirt_test.sh @@ -201,7 +201,7 @@ if [[ $COMPOSE_STATUS != FINISHED ]]; then fi # Stop watching the worker journal. -sudo kill ${WORKER_JOURNAL_PID} +sudo pkill -P ${WORKER_JOURNAL_PID} # Download the image. greenprint "📥 Downloading the image"