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