|
This article is about POSIX-style signals. For signals in event-driven processing, see Signal programming.
A signal is a limited form of inter-process communication used in Unix, Unix-like, and other POSIX-compliant operating systems. Essentially it is an asynchronous notification sent to a process in order to notify it of an event that occurred. When a signal is sent to a process, the operating system interrupts the process' normal flow of execution. Execution can be interrupted during any non-atomic instruction. If the process has previously registered a signal handler, that routine is executed. Otherwise the default signal handler is executed.
Sending signals
Handling signalsSignal handlers can be installed with the Signal handling is vulnerable to race conditions. Because signals are asynchronous, another signal (even of the same type) can be delivered to the process during execution of the signal handling routine. The Signals can cause the interruption of a system call in progress, leaving it to the application to manage a non-transparent restart. Signal handlers should be written in a way that doesn't result in any unwanted side-effects, e.g. errno alteration, signal mask alteration, signal disposition change, and other global process attribute changes. Use of non-reentrant functions, e.g. malloc or printf, inside signal handlers is also unsafe. Relationship with Hardware ExceptionsA process's execution may result in the generation of a hardware exception, for instance, if the process attempts to divide by zero or incurs a TLB miss. In Unix-like operating systems, this event automatically changes the processor context to start executing a kernel exception handler. With some exceptions, such as a page fault, the kernel has sufficient information to fully handle the event and resume the process's execution. In other exceptions, however, the kernel cannot proceed intelligently and must instead defer the exception handling operation to the faulting process. This deferral is achieved via the signal mechanism, wherein the kernel sends to the process a signal corresponding to the current exception. For example, if a process attempted to divide by zero on an x86 CPU, a divide error exception would be generated and cause the kernel to send the SIGFPE signal to the process. Similarly, if the process attempted to access a memory address outside of its virtual address space, the kernel would notify the process of this violation via a SIGSEGV signal. The exact mapping between signal names and exceptions is obviously dependent upon the CPU, since exception types differ between architectures. List of signalsThe Single Unix Specification specifies the following signals which are defined in <signal.h>:
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]. See also
External links
|
||||||||||||||||||||||||
This article is from Wikipedia. All text is available under the terms of the GNU Free Documentation License.
Mercedes Car
This site monitored by SitePinger.net