On
POSIX
The Portable Operating System Interface (POSIX) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines both the system- and user-level application programming interf ...
-compliant platforms, SIGHUP ("signal hang up") is a
signal
In signal processing, a signal is a function that conveys information about a phenomenon. Any quantity that can vary over space or time can be used as a signal to share messages between observers. The ''IEEE Transactions on Signal Processing'' ...
sent to a
process
A process is a series or set of activities that interact to produce a result; it may occur once-only or be recurrent or periodic.
Things called a process include:
Business and management
*Business process, activities that produce a specific se ...
when its controlling terminal is closed. It was originally designed to notify the process of a
serial line
Serial may refer to:
Arts, entertainment, and media The presentation of works in sequential segments
* Serial (literature), serialised literature in print
* Serial (publishing), periodical publications and newspapers
* Serial (radio and televisio ...
drop. SIGHUP is a
symbolic constant defined in the
header file
Many programming languages and other computer files have a directive, often called include (sometimes copy or import), that causes the contents of the specified file to be inserted into the original file. These included files are called copybooks ...
signal.h
.
History
Access to
computer systems
A computer is a machine that can be programmed to Execution (computing), carry out sequences of arithmetic or logical operations (computation) automatically. Modern digital electronic computers can perform generic sets of operations known as C ...
for many years consisted of connecting a
terminal
Terminal may refer to:
Computing Hardware
* Terminal (electronics), a device for joining electrical circuits together
* Terminal (telecommunication), a device communicating over a line
* Computer terminal, a set of primary input and output devic ...
to a mainframe system via a serial line and the
RS-232
In telecommunications, RS-232 or Recommended Standard 232 is a standard originally introduced in 1960 for serial communication transmission of data. It formally defines signals connecting between a ''DTE'' (''data terminal equipment'') such a ...
protocol
Protocol may refer to:
Sociology and politics
* Protocol (politics), a formal agreement between nation states
* Protocol (diplomacy), the etiquette of diplomacy and affairs of state
* Etiquette, a code of personal behavior
Science and technology
...
. When a system of software
interrupt
In digital computers, an interrupt (sometimes referred to as a trap) is a request for the processor to ''interrupt'' currently executing code (when permitted), so that the event can be processed in a timely manner. If the request is accepted, ...
s, called signals, was being developed, one of those signals 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
A modulator-demodulator or modem is a computer hardware device that converts data from a digital format into a format suitable for an analog transmission medium such as telephone or radio. A modem transmits data by Modulation#Digital modulati ...
. The system would detect the line was dropped via the lost
Data Carrier Detect
Data Carrier Detect, abbreviated as DCD, or alternately Carrier Detect abbreviated as CD, is a control signal present inside an RS-232 serial communications cable that goes between a computer and another device, such as a modem. This signal is a ...
(DCD) signal.
Signals have always been a convenient method of
inter-process communication
In computer science, inter-process communication or interprocess communication (IPC) refers specifically to the mechanisms an operating system provides to allow the processes to manage shared data. Typically, applications can use IPC, categori ...
(IPC), but in early implementations there were no user-definable signals (such as the later additions of
SIGUSR1 and SIGUSR2
Signals are standardized messages sent to a running program to trigger specific behavior, such as quitting or error handling. They are a limited form of inter-process communication (IPC), typically used in Unix, Unix-like, and other POSIX-compli ...
) 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 file
In computing, configuration files (commonly known simply as config files) are computer file, files used to configure the Parameter (computer programming), parameters and Initialization (programming), initial settings for some computer programs. T ...
s, or reinitialize. This convention survives to this day in packages such as
Apache
The Apache () are a group of culturally related Native American tribes in the Southwestern United States, which include the Chiricahua, Jicarilla, Lipan, Mescalero, Mimbreño, Ndendahe (Bedonkohe or Mogollon and Nednhi or Carrizaleño an ...
and
Sendmail
Sendmail is a general purpose internetwork email routing facility that supports many kinds of mail-transfer and delivery methods, including the Simple Mail Transfer Protocol (SMTP) used for email transport over the Internet.
A descendant of the ...
.
Modern usage
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. If a command is executed inside a terminal window and the terminal window is closed while the command process is still running, it receives SIGHUP.
[.]
If the process receiving SIGHUP is a
Unix shell
A Unix shell is a command-line Interpreter (computing), interpreter or shell (computing), shell that provides a command line user interface for Unix-like operating systems. The shell is both an interactive command language and a scripting langua ...
, then as part of
job control it will often intercept the signal and ensure that all stopped processes are continued before sending the signal to child processes (more precisely,
process group
In a POSIX-conformant operating system, a process group denotes a collection of one or more processes.
Among other things, a process group is used to control the distribution of a signal;
when a signal is directed to a process group, the signal i ...
s, represented internally by the shell as a "job"), which by default terminates them.
[.]
This can be circumvented in two ways. Firstly, the
Single UNIX Specification describes a shell utility called
nohup
nohup is a POSIX command which means "no hang up". Its purpose is to execute a command such that it ignores the HUP (hangup) signal and therefore does not stop when the user logs out.
Output that would normally go to the terminal goes to a file ...
, which can be used as a wrapper to start a program and make it ignore SIGHUP by default. Secondly, child process groups can be "disowned" by invoking
disown
Disownment occurs when a parent renounces or no longer accepts a child as a family member, usually due to reprehensible actions leading to serious emotional consequences. Different from giving a child up for adoption, it is a social and interper ...
with the
job id
In Unix and Unix-like operating systems, job control refers to control of jobs by a shell, especially interactively, where a "job" is a shell's representation for a process group. Basic job control features are the suspending, resuming, or termina ...
, which removes the process group from the shell's job table (so they will not be sent SIGHUP), or (optionally) keeps them in the job table but prevents them from receiving SIGHUP on shell termination.
Different shells also have other methods of controlling and managing SIGHUP, such as the
disown
Disownment occurs when a parent renounces or no longer accepts a child as a family member, usually due to reprehensible actions leading to serious emotional consequences. Different from giving a child up for adoption, it is a social and interper ...
facility of
ksh. Most modern
Linux distribution
A Linux distribution (often abbreviated as distro) is an operating system made from a software collection that includes the Linux kernel and, often, a package management system. Linux users usually obtain their operating system by downloading one ...
s documentation specify using
kill
Kill often refers to:
*Homicide, one human killing another
*cause death, to kill a living organism, to cause its death
Kill may also refer to:
Media
*'' Kill!'', a 1968 film directed by Kihachi Okamoto
* ''Kill'' (Cannibal Corpse album), 2006
* ...
-HUP
to send the SIGHUP signal.
[.]
Daemon
Daimon or Daemon (Ancient Greek: , "god", "godlike", "power", "fate") originally referred to a lesser deity or guiding spirit such as the daimons of ancient Greek religion and mythology and of later Hellenistic religion and philosophy.
The word ...
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.
Details
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.
SIGHUP can be
handled. That is,
programmer
A computer programmer, sometimes referred to as a software developer, a software engineer, a programmer or a coder, is a person who creates computer programs — often for larger computer software.
A programmer is someone who writes/creates ...
s can define the action they want to occur upon receiving a SIGHUP, such as calling a
function
Function or functionality may refer to:
Computing
* Function key, a type of key on computer keyboards
* Function model, a structured representation of processes in a system
* Function object or functor or functionoid, a concept of object-oriente ...
, ignoring it, or restoring the default action.
The default action on
POSIX
The Portable Operating System Interface (POSIX) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines both the system- and user-level application programming interf ...
-compliant systems is an abnormal termination.
References
{{reflist
See also
*
Unix signal
The asterisk ( ), from Late Latin , from Ancient Greek , ''asteriskos'', "little star", is a typographical symbol. It is so called because it resembles a conventional image of a heraldic star.
Computer scientists and mathematicians often vo ...
*
RS-232
In telecommunications, RS-232 or Recommended Standard 232 is a standard originally introduced in 1960 for serial communication transmission of data. It formally defines signals connecting between a ''DTE'' (''data terminal equipment'') such a ...
*
Computer terminal
A computer terminal is an electronic or electromechanical hardware device that can be used for entering data into, and transcribing data from, a computer or a computing system. The teletype was an example of an early-day hard-copy terminal and ...
Unix signals