From e0df8a80bfef92f1cf4719f487b74525030a5dad Mon Sep 17 00:00:00 2001 From: MickLesk Date: Tue, 21 Jul 2026 23:27:22 +0200 Subject: [PATCH] Don't destroy container on install-recovery menu read failure read -t returns >128 on a real timeout, but a lower/plain error code on a genuine read failure (e.g. broken/closed stdin, I/O error) - these were treated identically as "no response", so a user whose keystroke failed to be captured (e.g. a transient stdin I/O error) got their container silently destroyed instead of kept. Only auto-remove on an actual timeout; on a hard read failure, keep the container (reversible) and tell the user how to remove it manually. --- misc/build.func | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/misc/build.func b/misc/build.func index 0a8319cbd..29c88ed88 100644 --- a/misc/build.func +++ b/misc/build.func @@ -5140,7 +5140,10 @@ EOF echo -en "${YW}Select option [1-${max_option}] (default: 1, auto-remove in 60s): ${CL}" local response="" - if read -t 60 -r response; then + local read_rc + read -t 60 -r response + read_rc=$? + if [[ $read_rc -eq 0 ]]; then case "${response:-1}" in 1) # Remove container @@ -5359,13 +5362,20 @@ EOF fi ;; esac - else + elif [[ $read_rc -gt 128 ]]; then # Timeout - auto-remove echo "" msg_info "No response - removing container ${CTID}" pct stop "$CTID" &>/dev/null || true pct destroy "$CTID" &>/dev/null || true msg_ok "Container ${CTID} removed" + else + # read itself failed (e.g. broken/closed stdin, I/O error) rather than + # timing out - don't guess and destroy the container on a read we + # couldn't actually capture; keep it since that's the reversible choice. + echo "" + msg_error "Could not read your response (stdin error) - keeping container ${CTID} for safety." + msg_error "Remove it manually if not needed: pct destroy ${CTID}" fi # Force one final status update attempt after cleanup