From 53efcdc9df168720acd062e7e387b4f87e122f70 Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Mon, 2 Mar 2026 09:29:55 +0100 Subject: [PATCH] Redirect lxc-attach stdin; restore terminal Prevent the lxc-attach pipeline from consuming the host's stdin by redirecting its stdin from /dev/null, keeping /dev/tty available for the recovery menu after SIGINT or failures (avoids "read: read error: Input/output error"). Also restore terminal state after the pipeline by running `stty sane` (errors ignored). Applied these changes to both installation invocation sites in misc/build.func. --- misc/build.func | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/misc/build.func b/misc/build.func index 98a11f6b1..4233d831c 100644 --- a/misc/build.func +++ b/misc/build.func @@ -4100,10 +4100,16 @@ EOF' # - install script crashes before logging starts # - $STD/silent() not used for some commands # PIPESTATUS[0] gets the real exit code from lxc-attach (not from tee). + # Note: stdin is redirected from /dev/null so the pipeline does not consume + # the host's stdin/tty. This keeps /dev/tty usable for the recovery menu + # after SIGINT or failure (prevents "read: read error: Input/output error"). local _LXC_CAPTURE_LOG="/tmp/.install-capture-${SESSION_ID}.log" - lxc-attach -n "$CTID" -- bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/install/${var_install}.sh)" 2>&1 | tee "$_LXC_CAPTURE_LOG" + lxc-attach -n "$CTID" -- bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/install/${var_install}.sh)" &1 | tee "$_LXC_CAPTURE_LOG" local lxc_exit=${PIPESTATUS[0]} + # Restore terminal state after pipeline (tee/lxc-attach may leave it broken) + stty sane 2>/dev/null || true + unset CONTAINER_INSTALLING # Keep error handling DISABLED during failure detection and recovery @@ -4387,6 +4393,9 @@ EOF' echo "" echo -en "${YW}Select option [1-${max_option}] (default: 1, auto-remove in 60s): ${CL}" + # Ensure terminal is sane before reading input (lxc-attach|tee may corrupt tty state) + stty sane 2>/dev/null || true + if read -t 60 -r response &1 | tee "$_LXC_CAPTURE_LOG" + lxc-attach -n "$CTID" -- bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/install/${var_install}.sh)" &1 | tee "$_LXC_CAPTURE_LOG" local apt_retry_exit=${PIPESTATUS[0]} + stty sane 2>/dev/null || true set -Eeuo pipefail trap 'error_handler' ERR