diff --git a/src/entry.sh b/src/entry.sh index c4430465..f755c419 100644 --- a/src/entry.sh +++ b/src/entry.sh @@ -47,17 +47,21 @@ sed -u \ -e 's/failed to load Boot/skipped Boot/g' \ -e 's/0): Not Found/0)/g' & +output=$! + if ! enabled "$SHUTDOWN"; then - exec "${cmd[@]}" ${ARGS:+ $ARGS} >"$pipe" + exec "${cmd[@]}" ${ARGS:+ $ARGS} >"$pipe" 2>&1 fi -"${cmd[@]}" ${ARGS:+ $ARGS} >"$pipe" & +"${cmd[@]}" ${ARGS:+ $ARGS} >"$pipe" 2>&1 & pid=$! ( sleep 30; boot ) & rc=0 wait "$pid" || rc=$? +wait "$output" || : + [ -f "$QEMU_END" ] && exit "$rc" sleep 1 & wait $! diff --git a/src/power.sh b/src/power.sh index b2fc1634..aa300dd2 100644 --- a/src/power.sh +++ b/src/power.sh @@ -186,6 +186,12 @@ cleanupHelpers() { finish() { local reason=$1 + local failed=0 + + if [ ! -f "$QEMU_END" ] && (( reason != 0 )); then + failed=1 + fi + touch "$QEMU_END" forceKillQemu "$reason" @@ -200,7 +206,13 @@ finish() { warn "Timed out while waiting for $(app) to exit!" fi - (( reason != 1 )) && echo && echo "❯ Shutdown completed!" + echo + + if (( failed == 0 )); then + echo "❯ Shutdown completed!" + else + error "QEMU exited unexpectedly!" + fi exit "$reason" }