diff --git a/misc/api.func b/misc/api.func index 21aa9b057..dad7a2ebe 100644 --- a/misc/api.func +++ b/misc/api.func @@ -178,6 +178,7 @@ explain_exit_code() { 126) echo "Command invoked cannot execute (permission problem?)" ;; 127) echo "Command not found" ;; 128) echo "Invalid argument to exit" ;; + 129) echo "Killed by SIGHUP (terminal closed / hangup)" ;; 130) echo "Aborted by user (SIGINT)" ;; 134) echo "Process aborted (SIGABRT - possibly Node.js heap overflow)" ;; 137) echo "Killed (SIGKILL / Out of memory?)" ;; @@ -912,7 +913,7 @@ categorize_error() { 134 | 137) echo "resource" ;; # Signal/Process errors (SIGTERM, SIGPIPE, SIGSEGV) - 139 | 141 | 143) echo "signal" ;; + 129 | 139 | 141 | 143) echo "signal" ;; # Shell errors (general error, syntax error) 1 | 2) echo "shell" ;; diff --git a/misc/core.func b/misc/core.func index e4c7efcc6..74b98ac4f 100644 --- a/misc/core.func +++ b/misc/core.func @@ -1641,4 +1641,17 @@ function get_lxc_ip() { # SIGNAL TRAPS # ============================================================================== +# ------------------------------------------------------------------------------ +# on_hup_keepalive() +# +# - SIGHUP (terminal hangup) trap handler +# - Keeps long-running scripts alive if terminal/SSH session disconnects +# - Stops spinner safely and writes warning to active log +# ------------------------------------------------------------------------------ +on_hup_keepalive() { + stop_spinner + log_msg "[WARN] Received SIGHUP (terminal hangup). Continuing execution in background." +} + +trap 'on_hup_keepalive' HUP trap 'stop_spinner' EXIT INT TERM diff --git a/misc/error_handler.func b/misc/error_handler.func index 87c2b4883..bd6d98929 100644 --- a/misc/error_handler.func +++ b/misc/error_handler.func @@ -49,6 +49,7 @@ if ! declare -f explain_exit_code &>/dev/null; then 126) echo "Command invoked cannot execute (permission problem?)" ;; 127) echo "Command not found" ;; 128) echo "Invalid argument to exit" ;; + 129) echo "Killed by SIGHUP (terminal closed / hangup)" ;; 130) echo "Terminated by Ctrl+C (SIGINT)" ;; 134) echo "Process aborted (SIGABRT - possibly Node.js heap overflow)" ;; 137) echo "Killed (SIGKILL / Out of memory?)" ;;