From 3aab9e97b5492665824a7e729b8bd8135c36db04 Mon Sep 17 00:00:00 2001 From: Kroese Date: Wed, 5 Aug 2026 20:44:07 +0200 Subject: [PATCH] fix: Race between signal handler and cleanup (#2062) --- src/power.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/power.sh b/src/power.sh index a668ec77..f4bcc3db 100644 --- a/src/power.sh +++ b/src/power.sh @@ -483,7 +483,7 @@ gracefulShutdown() { code=$(signalCode "$sig") - if [ -f "$QEMU_END" ]; then + if (( SHUTDOWN_SIGNAL != 0 )); then # A second Ctrl-C during an active shutdown skips the remaining grace period # and lets the shutdown loop force QEMU down immediately. @@ -497,12 +497,12 @@ gracefulShutdown() { return fi + SHUTDOWN_SIGNAL=$code + # Signal handlers must complete their own error handling and cleanup without # errexit terminating the shell partway through the shutdown sequence. set +e - SHUTDOWN_SIGNAL=$code - touch "$QEMU_END" echo && info "Received $sig signal, sending ACPI shutdown signal..." # Interactive startup may receive a signal before the PID file appears, so