From fec4f876e7223c7da4b30d97bbbd581347ddba16 Mon Sep 17 00:00:00 2001 From: Kroese Date: Wed, 5 Aug 2026 21:09:01 +0200 Subject: [PATCH] fix: Race between signal handler and cleanup (#1350) --- src/power.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/power.sh b/src/power.sh index 3b609d3..69810e9 100644 --- a/src/power.sh +++ b/src/power.sh @@ -344,7 +344,7 @@ graceful_shutdown() { code=$(signalCode "$sig") - if [ -f "$QEMU_END" ]; then + if (( SHUTDOWN_SIGNAL != 0 )); then # A second Ctrl-C is the explicit user request to skip the remaining # graceful-shutdown wait and proceed to forced cleanup. @@ -358,11 +358,14 @@ graceful_shutdown() { return fi - set +e start=$SECONDS SHUTDOWN_SIGNAL=$code + # Shutdown handlers must continue through missing processes and failed cleanup + # commands instead of being aborted by errexit. + set +e touch "$QEMU_END" + echo && info "Received $sig signal, sending shutdown command..." if ! readQemuPid pid; then