Causes of Signal: Unix Unix-Like
Causes of Signal: Unix Unix-Like
Signals are similar to interrupts, the difference being that interrupts are mediated
by the processor and handled by the kernel while signals are mediated by the
kernel (possibly via system calls) and handled by processes. The kernel may pass
an interrupt as a signal to the process that caused it.
Causes of signal
A signal reports the occurrence of an exceptional event. These are some of the events that can
cause a signal:
Exceptions such as division by zero or a segmentation violation will generate signals (here,
SIGFPE "floating point exception" and SIGSEGV "segmentation violation" respectively, which
both by default cause a core dump and a program exit).
The kernel can generate signals to notify processes of events. For example, SIGPIPE will be
generated when a process writes to a pipe which has been closed by the reader; by default, this
causes the process to terminate, which is convenient when constructing shell pipelines.
Typing certain key combinations at the controlling terminal of a running process causes the
system to send it certain signals:
Ctrl-C (in older Unixes, DEL) sends an INT signal ("interrupt", SIGINT); by default, this
causes the process to terminate.
Ctrl-Z sends a TSTP signal ("terminal stop", SIGTSTP); by default, this causes the
process to suspend execution.
Ctrl-\ sends a QUIT signal (SIGQUIT); by default, this causes the process to terminate
and dump core.
Ctrl-T (not supported on all UNIXes) sends an INFO signal (SIGINFO); by default, and
if supported by the command, this causes the operating system to show information about
the running command.
These default key combinations with modern operating systems can be changed with the stty
command.