DB / Linux Kernel / Operating System / SIGHUP (Signal 1)
WARNING

Linux Kernel / Operating System Hangup Signal

SIGHUP is a signal sent to a process when its controlling terminal is closed (e.g., SSH session disconnect, terminal window close) or when a process is explicitly requested to re-read its configuration files. By default, it terminates the receiving process.

Common Causes

  • Closing a terminal window or SSH session where a process was running in the foreground or background without proper detachment (e.g., `nohup`, `screen`, `tmux`).
  • Parent process termination, causing child processes to receive SIGHUP.
  • Network interruptions leading to SSH session disconnections.
  • Explicitly sending SIGHUP to a daemon to trigger a configuration reload (e.g., `nginx -s reload`, `kill -HUP <pid>`).

How to Fix

1 Use `nohup` for long-running background processes

Run a command that should continue executing even after the terminal is closed, preventing SIGHUP from terminating it. Output is redirected to `nohup.out` by default.

BASH
$ nohup your_command_here &

2 Use `screen` or `tmux` for persistent sessions

Create a persistent terminal session that can be detached and reattached later. Processes run within these sessions are immune to terminal disconnections.

BASH
$ screen # or tmux your_command_here # To detach: Ctrl+A, D (for screen) or Ctrl+B, D (for tmux)

3 Configure daemons to handle SIGHUP for reload

Many server applications (e.g., Nginx, Apache, Systemd services) are designed to re-read their configuration when they receive SIGHUP, rather than terminating. Use the appropriate service management command.

BASH
$ sudo systemctl reload your_service_name # Or for direct process: sudo kill -HUP <pid_of_process>

4 Use `disown` for already running background processes

If a process is already running in the background (`&`) and you want to detach it from the terminal's job control so it doesn't receive SIGHUP, use `disown`.

BASH
$ your_command_here & disown -h %1 # %1 refers to the job number, check with 'jobs'