Repository navigation
feat: let an install survive a closed console / dont sighup installs - #167
Conversation
Closing the Proxmox shell or losing the SSH session sent SIGHUP to the host script, which posted "aborted", stopped the container and left it half-built; the install inside was killed with it. Both now carry on: on_hangup moves the output to the active log instead of exiting, silent() starts external programs with SIGHUP ignored so the apt, npm or cargo of the moment keeps running, a clean install leaves a .done marker, and when lxc-attach dies with the terminal the host follows the container's markers (.failed, .done, the install's pid) until it can report. The failure prompt keeps the container when nobody is there to answer. Ctrl-C still aborts.
Try this branchThe engine and the scripts resolve independently, so a production script can COMMUNITY_SCRIPTS_CORE_URL=https://raw.githubusercontent.com/community-scripts/core/feat/survive-console-hangup \
bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/ct/debian.sh)"Swap This PR touches both backends. Worth running on a Proxmox VE and an Incus host. Run a script from a fork as wellcurl -fsSL https://raw.githubusercontent.com/community-scripts/core/feat/survive-console-hangup/tools/run.sh |
bash -s -- https://raw.githubusercontent.com/YOU/DevScripts/your-branch ct/debian.sh \
https://raw.githubusercontent.com/community-scripts/core/feat/survive-console-hangupNote that Useful flags while testing
|
A redirected call to a shell function makes bash save fd 1 and fd 2 and restore them when the call returns. silent() makes exactly that call, so the hangup trap's redirect was undone the moment the interrupted command finished, and stdout pointed at the terminal that was gone. The first message after it failed with EIO, which under errexit ended the install without reaching on_exit -- the half-built container and the missing status the telemetry reported as an abort. silent() and the msg_* helpers now re-apply the redirect where no redirection is in effect.
incus ends an exec session the moment its client goes away and takes the command with it -- measured on real hardware: the process was gone and its SIGHUP trap had never run, where the same test under lxc-attach survived and finished. The host made it worse by force-stopping the container on SIGHUP and reporting a failure. The install now runs detached from the exec session, with its input coming through a fifo while a console exists and its output followed from the host. Closing the console costs the view and the keyboard, not the installation; the host waits for the markers the install leaves.
…hangup # Conflicts: # incus/backend.func # pve/backend.func
|
Basically, it's quite simple: this feature avoids the thousands of “aborts” in the telemetry. It keeps the session active until the installation is complete, even if the web terminal or SSH connection was terminated for some reason. |
✍️ Description
Closing the Proxmox shell or losing the SSH session sent SIGHUP to the host script, which posted "aborted", stopped the container and left it half-built; the install inside was killed with it. Both now carry on: on_hangup moves the output to the active log instead of exiting, silent() starts external programs with SIGHUP ignored so the apt, npm or cargo of the moment keeps running, a clean install leaves a .done marker, and when lxc-attach dies with the terminal the host follows the container's markers (.failed, .done, the install's pid) until it can report. The failure prompt keeps the container when nobody is there to answer. Ctrl-C still aborts.
🔗 Related Issue
Fixes #
✅ Prerequisites (X in brackets)
API.txtwas updated to match.🤖 AI Assistance (X in brackets)
🛠️ Type of Change (X in brackets)
README,docs/,CONTRIBUTING.md, or other docs.