On POSIX-compliant platforms, SIGHUP is a signal sent to a process when its controlling terminal is closed. (It was originally designed to notify the process of a serial line drop). SIGHUP is a symbolic constant defined in the header file
Access to computer systems for many years consisted of connecting a terminal to a mainframe system via a serial line and the RS-232 protocol. For this reason, when a system of software interrupts, called signals, were being developed, a signal was designated for use on "Hangup".
SIGHUP would be sent to programs when the serial line was dropped, often because the connected user terminated the connection by hanging up the modem. The system would detect the line was dropped via the lost DCD "carrier detect" signal.
Signals have always been a convenient method of inter-process communication (IPC), but in early implementations there were no user-definable signals (such as the later additions of SIGUSR1 and SIGUSR2) that programs could intercept and interpret for their own purposes. For this reason, applications that did not require a controlling terminal, such as daemons, would re-purpose SIGHUP as a signal to re-read configuration files, or reinitialize. This convention survives to this day in packages such as Apache and Sendmail.
With the decline of access via serial line, the meaning of SIGHUP has changed somewhat on modern systems, often meaning a controlling pseudo or virtual terminal has been closed (i.e. a command is executed inside a terminal window and the terminal window is closed while the command process is still running).
Different shells also have other methods of controlling and managing SIGHUP, such as the disown facility of GNU bash. Most modern Linux distributions documentation specify using kill -HUP <processID> to send the SIGHUP signal.
Daemon programs sometimes use SIGHUP as a signal to restart themselves, the most common reason for this being to re-read a configuration file that has been changed.
Symbolic signal names are used because signal numbers can vary across platforms, but XSI-conformant systems allow the use of the numeric constant 1 to be used to indicate a SIGHUP, which the vast majority of systems in fact use.
The default action on POSIX-compliant systems is an abnormal termination.
- Kerrisk, Michael, ed. (25 July 2009), "SIGNAL(7)", Linux Programmer's Manual (version 3.22), The Linux Kernel Archives, retrieved 23 September 2009.
- Garrels, Machtelt, ed. (27 December 2008), "Signals", Bash Guide for Beginners, ver. 1.11, The Linux Documentation Project, retrieved 23 September 2009.
- Kerrisk, Michael, ed. (25 July 2009), "KILL(2)", Linux Programmer's Manual (version 3.22), The Linux Kernel Archives, retrieved 23 September 2009.