From 12080365866461b17dcb0f807114d2f48b548c2a Mon Sep 17 00:00:00 2001 From: shipitdev Date: Thu, 20 Aug 2026 23:36:47 +0530 Subject: [PATCH] build_library/qemu_template: use POSIX kill -0 for swtpm cleanup watcher Signed-off-by: shipitdev --- build_library/qemu_template.sh | 2 +- changelog/bugfixes/2026-08-20-qemu-swtpm-proc-cleanup.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 changelog/bugfixes/2026-08-20-qemu-swtpm-proc-cleanup.md diff --git a/build_library/qemu_template.sh b/build_library/qemu_template.sh index 32445e85274..31a3297d7a3 100755 --- a/build_library/qemu_template.sh +++ b/build_library/qemu_template.sh @@ -181,7 +181,7 @@ if [ -n "${SWTPM_DIR}" ]; then # The swtpm process exits if qemu disconnects but if we never started qemu because # this script fails or qemu failed to start, we need to kill the process. # The EXIT trap is already in use by the config drive cleanup and anyway doesn't work with kill -9. - (while [ -e "/proc/${PARENT}" ]; do sleep 1; done; kill "${SWTPM_PROC}" 2>/dev/null; exit 0) & + (while kill -0 "${PARENT}" 2>/dev/null; do sleep 1; done; kill "${SWTPM_PROC}" 2>/dev/null; exit 0) & set -- -chardev "socket,id=chrtpm,path=${SWTPM_SOCK}" -tpmdev emulator,id=tpm0,chardev=chrtpm -device "${TPM_DEV}",tpmdev=tpm0 "$@" fi diff --git a/changelog/bugfixes/2026-08-20-qemu-swtpm-proc-cleanup.md b/changelog/bugfixes/2026-08-20-qemu-swtpm-proc-cleanup.md new file mode 100644 index 00000000000..cde6d9cecf9 --- /dev/null +++ b/changelog/bugfixes/2026-08-20-qemu-swtpm-proc-cleanup.md @@ -0,0 +1 @@ +- Fixed swtpm process cleanup in QEMU launcher on macOS by using POSIX kill -0 instead of checking Linux-only /proc.