Signal (computing)
From Free net encyclopedia
A signal is an asynchronous event transmitted between one process and another.
In Unix, Unix-like, and other POSIX-compliant operating systems, there is a uniform way of using signals, such as making use of the kill()
system call to send signals, and the signal()
or sigaction()
system calls are used to set up signal handlers—functions to "catch" the signal and handle the signal in a particular way.
The Single Unix Specification specifies the following signals for <signal.h>:
- SIGABRT - process aborted
- SIGALRM - signal raised by alarm
- SIGBUS - bus error "access to undefined portion of memory object"(SUS)
- SIGCHLD - child process terminated, stopped (*or continued)
- SIGCONT - continue if stopped
- SIGFPE - floating point exception -- "erroneous arithmetic operation"(SUS)
- SIGHUP - hangup
- SIGILL - illegal instruction
- SIGINT - interrupt
- SIGKILL - kill
- SIGPIPE - write to pipe with no one reading
- SIGQUIT - quit
- SIGSEGV - segmentation violation
- SIGSTOP - stop executing
- SIGTERM - termination
- SIGTSTP - terminal stop signal
- SIGTTIN - background process attempting to read ("in")
- SIGTTOU - background process attempting to write ("out")
- SIGUSR1 - user defined 1
- SIGUSR2 - user defined 2
- *SIGPOLL - pollable event
- *SIGPROF - profiling timer expired
- *SIGSYS - bad syscall
- *SIGTRAP - trace/breakpoint trap
- SIGURG - urgent data available on socket
- *SIGVTALRM - signal raised by timer counting virtual time -- "virtual timer expired"(SUS)
- *SIGXCPU - CPU time limit exceeded
- *SIGXFSZ - file size limit exceeded
Note: Where a section is marked by an asterisk, this denotes an X/Open System Interfaces (XSI) extension. Wording in quotes appended with (SUS) denotes the wording from the SUS[1].
Conditions
The following conditions can generate a signal(1):
- When user presses terminal keys, the terminal will generate a signal. For example, when the user breaks a program by CTRL + C key pair.
- Hardware exceptions can generate signals, too: Division by 0, invalid memory reference. Inexperienced programmers often get SIGSEGV (Segmentation Violation signal) because of an invalid address in a pointer.
- Processes can send signals to themselves by using kill(2) system call (If permissions allow).
- Kernel can generate signal to inform processes when something happens. For example, SIGPIPE will be generated when a process writes to a pipe which has been closed by the reader.
Signals can cause the interruption of a system call in progress, leaving it to the application to manage a non-transparent restart.
External links
- UNIX and Reliable POSIX Signals by Baris Simsek