Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Signal (IPC)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{short description|Form of inter-process communication in computer systems}} {{About|form of inter-process communication|event-driven processing concept|Signal programming}} {{Use dmy dates|date=February 2021}} {{More citations needed|date=August 2012}} '''Signals''' are standardized messages sent to a running [[Computer program|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]]-compliant operating systems. A signal is an [[Asynchrony (computer programming)|asynchronous]] notification sent to a [[Process (computing)|process]] or to a specific [[Thread (computing)|thread]] within the same process to notify it of an event. Common uses of signals are to interrupt, suspend, terminate or [[kill (command)|kill]] a process. Signals originated in 1970s [[Bell Labs]] Unix and were later specified in the [[POSIX]] standard. When a signal is sent, the operating system interrupts the target process's normal [[Control flow|flow of execution]] to deliver the signal. Execution can be interrupted during any [[Atomic operation|non-atomic instruction]]. If the process has previously registered a '''signal handler''', that routine is executed. Otherwise, the default signal handler is executed. Embedded programs may find signals useful for inter-process communications, as signals are notable for their [[algorithmic efficiency]]. Signals are similar to [[interrupt]]s, the difference being that interrupts are mediated by the [[Central_processing_unit|CPU]] and handled by the [[Kernel (operating system)|kernel]] while signals are mediated by the kernel (possibly via system calls) and handled by individual [[Process_(computing)|processes]].{{cn |date=May 2022}} The kernel may pass an interrupt as a signal to the process that caused it (typical examples are [[SIGSEGV]], [[SIGBUS]], [[#SIGILL|SIGILL]] and [[#SIGFPE|SIGFPE]]). ==History== * [[Version 1 Unix]] (1971) had separate [[system call]]s to catch interrupts, quits, and machine traps. * {{tt|kill}} appeared in [[Version 2 Unix|Version 2]] (1972). * [[Version 4 Unix|Version 4]] (1973) combined all traps into one call, {{tt|signal}}. * [[Version 5 Unix|Version 5]] (1974) could send arbitrary signals.<ref name="reader">{{cite tech report |first1=M. D. |last1=McIlroy |author-link1=Doug McIlroy |year=1987 |url=https://www.cs.dartmouth.edu/~doug/reader.pdf |title=A Research Unix reader: annotated excerpts from the Programmer's Manual, 1971–1986 |series=CSTR |number=139 |institution=Bell Labs}}</ref> * In [[Version 7 Unix|Version 7]] (1979) each numbered trap received a symbolic name. * [[Plan 9 from Bell Labs]] (late 80s) replaced signals with ''notes'', which permit sending short, arbitrary strings.<ref>{{cite web |last1=Gagliardi |first1=Pietro |title=C Programming in Plan 9 from Bell Labs |url=https://doc.cat-v.org/plan_9/programming/c_programming_in_plan_9 |website=doc.cat-v.org |access-date=22 January 2022}}</ref> ==Sending signals== The {{tt|[[Kill (command)|kill]](2)}} system call sends a specified signal to a specified process, if permissions allow. Similarly, the {{tt|[[kill (command)|kill(1)]]}} command allows a user to send signals to processes. The {{tt|raise(3)}} library function sends the specified signal to the current process. [[Exception handling|Exceptions]] such as [[division by zero]], [[segmentation violation]] ([[#SIGSEGV|SIGSEGV]]), and floating point exception ([[#SIGFPE|SIGFPE]]) will cause a [[core dump]] and terminate the program. The kernel can generate signals to notify processes of events. For example, [[#SIGPIPE|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 [[Pipeline (Unix)|shell pipelines]]. Typing certain key combinations at the [[Computer terminal|controlling terminal]] of a running process causes the system to send it certain signals:<ref>{{cite web |title=Termination Signals |url=https://www.gnu.org/software/libc/manual/html_node/Termination-Signals.html |website=The GNU C Library)}}</ref> * [[Control-C|Ctrl-C]] (in older Unixes, DEL) sends an INT signal ("interrupt", [[#SIGINT|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.<ref>{{cite web |title=Job Control Signals |url=https://www.gnu.org/software/libc/manual/html_node/Job-Control-Signals.html |website=The GNU C Library}}</ref> * [[Control-\|Ctrl-\]] sends a QUIT signal ([[#SIGQUIT|SIGQUIT]]); by default, this causes the process to terminate and dump core. * [[Status key|Ctrl-T]] (not supported on all UNIXes) sends an INFO signal ([[#SIGINFO|SIGINFO]]); by default, and if supported by the command, this causes the operating system to show information about the running command.<ref>{{cite web |title=Miscellaneous Signals |url=https://www.gnu.org/software/libc/manual/html_node/Miscellaneous-Signals.html |website=The GNU C Library}}</ref> These default key combinations with modern operating systems can be changed with the {{tt|[[stty]]}} command. ==Handling signals== Signal handlers can be installed with the [[sigaction|{{tt|signal(2)}} or {{tt|sigaction(2)}}]] system call. If a signal handler is not installed for a particular signal, the default handler is used. Otherwise the signal is intercepted and the signal handler is invoked. The process can also specify two default behaviors, without creating a handler: ignore the signal (SIG_IGN) and use the default signal handler (SIG_DFL). There are two signals which cannot be intercepted and handled: [[#SIGKILL|SIGKILL]] and [[SIGSTOP]]. ===Risks=== Signal handling is vulnerable to [[race condition]]s. As signals are asynchronous, another signal (even of the same type) can be delivered to the process during execution of the signal handling routine. The {{tt|sigprocmask(2)}} call can be used to block and unblock delivery of signals. Blocked signals are not delivered to the process until unblocked. Signals that cannot be ignored (SIGKILL and SIGSTOP) cannot be blocked. Signals can cause the interruption of a system call in progress, leaving it to the application to manage a [[PCLSRing|non-transparent restart]]. Signal handlers should be written in a way that does not result in any unwanted side-effects, e.g. {{tt|[[errno.h|errno]]}} alteration, signal mask alteration, signal disposition change, and other global [[Process (computing)|process]] attribute changes. Use of non-[[Reentrancy (computing)|reentrant]] functions, e.g., {{tt|[[malloc]]}} or {{tt|[[printf]]}}, inside signal handlers is also unsafe. In particular, the POSIX specification and the Linux man page {{Tt|signal (7)}} require that all system functions directly or ''indirectly'' called from a signal function are ''async-signal safe''.<ref>{{Cite web|title=The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition: System Interfaces Chapter 2|url=https://pubs.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_04.html#tag_02_04|access-date=2020-12-20|website=pubs.opengroup.org}}</ref><ref>{{Cite web|title=signal(7) - Linux manual page|url=https://man7.org/linux/man-pages/man7/signal.7.html|access-date=2020-12-20|website=man7.org}}</ref> The {{tt|signal-safety(7)}} man page gives a list of such async-signal safe system functions (practically the [[system call]]s), otherwise it is an [[undefined behavior]].<ref>{{Cite web|title=signal-safety(7) - Linux manual page|url=https://man7.org/linux/man-pages/man7/signal-safety.7.html|access-date=2020-12-20|website=man7.org}}</ref> It is suggested to simply set some {{code|volatile sig_atomic_t}} variable in a signal handler, and to test it elsewhere.<ref>{{Cite web|title=The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition: <signal.h>|url=https://pubs.opengroup.org/onlinepubs/009695399/basedefs/signal.h.html|access-date=2020-12-20|website=pubs.opengroup.org}}</ref> Signal handlers can instead put the signal into a [[Queue (abstract data type)|queue]] and immediately return. The main thread will then continue "uninterrupted" until signals are taken from the queue, such as in an [[event loop]]. "Uninterrupted" here means that operations that [[Blocking (computing)|block]] may return prematurely and [[PCLSRing|must be resumed]], as mentioned above. Signals should be processed from the queue on the main thread and not by [[Thread pool|worker pools]], as that reintroduces the problem of asynchronicity. However, managing a queue is not possible in an async-signal safe way with only {{tt|sig_atomic_t}}, as only single reads and writes to such variables are guaranteed to be atomic, not increments or (fetch-and)-decrements, as would be required for a queue. Thus, effectively, only one signal per handler can be queued safely with {{tt|sig_atomic_t}} until it has been processed. ==Relationship with hardware exceptions== A [[Process (computing)|process]]'s execution may result in the generation of a hardware [[Exception handling|exception]], for instance, if the process attempts to divide by zero or incurs a [[page fault]]. In [[Unix-like]] operating systems, this event automatically changes the processor [[Context (computing)|context]] to start executing a [[Kernel (operating system)|kernel]] [[Exception handling|exception handler]]. In case of some exceptions, such as a [[page fault]], the kernel has sufficient information to fully handle the event itself and resume the process's execution. Other exceptions, however, the kernel cannot process intelligently and it 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 integer divide by zero on an [[x86]] [[Central processing unit|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 [[segmentation fault|SIGSEGV]] ([[segmentation fault|segmentation violation]] signal). The exact mapping between signal names and exceptions is obviously dependent upon the CPU, since exception types differ between architectures. ==POSIX signals== The list below documents the signals specified in the [[Single UNIX Specification|Single Unix Specification]] Version 5. All signals are defined as macro constants in the <code><signal.h></code> header file. The name of the macro constant consists of a "SIG" [[prefix]] followed by a mnemonic name for the signal. A process can define [[C signal handling|how to handle incoming POSIX signals]]. If a process does not define a behaviour for a signal, then the ''default handler'' for that signal is being used. The table below lists some default actions for POSIX-compliant UNIX systems, such as [[FreeBSD]], [[OpenBSD]] and [[Linux]]. {| class="wikitable sortable" |- ! Signal !! data-sort-type="number"|Portable<br/>number !! Default action !! class="unsortable"|Description |- | SIGABRT || style="text-align:right" | 6 || {{terminated|Terminate}} (core dump) || Process abort signal |- | SIGALRM || style="text-align:right" | 14 || {{terminated|Terminate}} || Alarm clock |- | SIGBUS || {{n/a}} || {{terminated|Terminate}} (core dump) || Access to an undefined portion of a memory object |- | SIGCHLD || {{n/a}} || style="text-align:center" | Ignore || Child process terminated, stopped, or continued |- | SIGCONT || {{n/a}} || style="text-align:center" | Continue || Continue executing, if stopped |- | SIGFPE || style="text-align:right" | 8 || {{terminated|Terminate}} (core dump) || Erroneous arithmetic operation |- | SIGHUP || style="text-align:right" | 1 || {{terminated|Terminate}} || Hangup |- | SIGILL || style="text-align:right" | 4 || {{terminated|Terminate}} (core dump) || Illegal instruction |- | SIGINT || style="text-align:right" | 2 || {{terminated|Terminate}} || Terminal interrupt signal |- | SIGKILL || style="text-align:right" | 9 || {{terminated|Terminate}} || Kill (cannot be caught or ignored) |- | SIGPIPE || style="text-align:right" | 13 || {{terminated|Terminate}} || Write on a pipe with no one to read it |- | SIGQUIT || style="text-align:right" | 3 || {{terminated|Terminate}} (core dump) || Terminal quit signal |- | SIGSEGV || style="text-align:right" | 11 || {{terminated|Terminate}} (core dump) || Invalid memory reference |- | SIGSTOP || {{n/a}} || {{dropped|Stop}} || Stop executing (cannot be caught or ignored) |- | SIGSYS || {{n/a}} || {{terminated|Terminate}} (core dump) || Bad system call |- | SIGTERM || style="text-align:right" | 15 || {{terminated|Terminate}} || Termination signal |- | SIGTRAP || style="text-align:right" | 5 || {{terminated|Terminate}} (core dump) || Trace/breakpoint trap |- | SIGTSTP || {{n/a}} || {{dropped|Stop}} || Terminal stop signal |- | SIGTTIN || {{n/a}} || {{dropped|Stop}} || Background process attempting read |- | SIGTTOU || {{n/a}} || {{dropped|Stop}} || Background process attempting write |- | SIGUSR1 || {{n/a}} || {{terminated|Terminate}} || User-defined signal 1 |- | SIGUSR2 || {{n/a}} || {{terminated|Terminate}} || User-defined signal 2 |- | SIGURG || {{n/a}} || style="text-align:center" | Ignore || [[Out-of-band data]] is available at a socket |- | SIGVTALRM || {{N/A}} || {{terminated|Terminate}} || Virtual timer expired |- | SIGXCPU || {{n/a}} || {{terminated|Terminate}} (core dump) || CPU time limit exceeded |- | SIGXFSZ || {{n/a}} || {{terminated|Terminate}} (core dump) || File size limit exceeded |- | SIGWINCH || {{n/a}} || style="text-align:center" | Ignore || Terminal window size changed |} ; ''Portable number:'' : For most signals the corresponding signal number is implementation-defined. This column lists the numbers specified in the POSIX standard.<ref>{{cite web|title=IEEE Std 1003.1-2017 - kill|url=https://pubs.opengroup.org/onlinepubs/9699919799/utilities/kill.html|publisher=IEEE, Open Group|quote=The correspondence between integer values and the ''sig'' value used is shown in the following list. The effects of specifying any ''signal_number'' other than those listed below are undefined.}}</ref> ; ''Actions explained:'' : '''Terminate'''{{snd}} Abnormal termination of the process. The process is terminated with all the consequences of _exit() except that the status made available to wait() and waitpid() indicates abnormal termination by the specified signal. : '''Terminate (core dump)'''{{snd}} Abnormal termination of the process. Additionally, implementation-defined abnormal termination actions, such as creation of a core file, may occur. : '''Ignore'''{{snd}} Ignore the signal. : '''Stop'''{{snd}} Stop (or suspend) the process. : '''Continue'''{{snd}} Continue the process, if it is stopped; otherwise, ignore the signal. ; {{mono|{{vanchor|SIGABRT}}}} and {{mono|{{vanchor|SIGIOT}}}} : The SIGABRT signal is sent to a process to tell it to [[Abort (computing)|'''abort''']], i.e. to terminate. The signal is usually initiated by the process itself when it calls [[C process control#abort|<code>abort()</code>]] function of the [[C Standard Library]], but it can be sent to the process from outside like any other signal. : SIGIOT indicates that the CPU has executed an explicit "trap" instruction (without a defined function), or an unimplemented instruction (when emulation is unavailable). ::''Note: "input/output trap" is a misnomer for any CPU "trap" instruction. The term reflects early usage of such instructions, predominantly to implement I/O functions, but they are not inherently tied to device I/O and may be used for other purposes such as communication between virtual & real hosts.'' : SIGIOT and SIGABRT are typically the same signal, and receipt of that signal may indicate any of the conditions above. ; {{mono|{{vanchor|SIGALRM}}}}, {{mono|{{vanchor|SIGVTALRM}}}} and {{mono|{{vanchor|SIGPROF}}}} : The SIGALRM, SIGVTALRM and SIGPROF signals are sent to a process when the corresponding time limit is reached. The process sets these time limits by calling <code>alarm</code> or <code>setitimer</code>. The time limit for SIGALRM is based on real or clock time; SIGVTALRM is based on CPU time used by the process; and SIGPROF is based on CPU time used by the process and by the system on its behalf (known as a ''profiling timer''). On some systems SIGALRM may be used internally by the implementation of the <code>sleep</code> function. ; {{mono|{{vanchor|SIGBUS}}}} : The [[SIGBUS]] signal is sent to a process when it causes a '''[[bus error]]'''. The conditions that lead to the signal being sent are, for example, incorrect memory access alignment or non-existent physical address. ; {{mono|{{vanchor|SIGCHLD}}}} : The [[child process|SIGCHLD]] signal is sent to a process when a '''[[child process]]''' [[exit (system call)|terminates]], is stopped, or resumes after being stopped. One common usage of the signal is to instruct the operating system to clean up the resources used by a child process after its termination without an explicit call to the <code>[[wait (system call)|wait]]</code> system call. ; {{mono|{{vanchor|SIGCONT}}}} : The [[SIGCONT]] signal instructs the operating system to '''continue''' (restart) a process previously paused by the SIGSTOP or SIGTSTP signal. One important use of this signal is in [[job control (Unix)|job control]] in the [[Unix shell]]. ; {{mono|{{vanchor|SIGFPE}}}} : The SIGFPE signal is sent to a process when an exceptional (but not necessarily erroneous) condition has been detected in the floating-point or integer arithmetic hardware. This may include [[division by zero]], floating-point underflow or overflow, [[integer overflow]], an invalid operation or an inexact computation. Behaviour may differ depending on hardware. ; {{mono|{{vanchor|SIGHUP}}}} : The [[SIGHUP]] signal is sent to a process when its controlling terminal is closed. It was originally designed to notify the process of a [[RS-232|serial line]] drop (a '''hangup'''). In modern systems, this signal usually means that the controlling [[Terminal emulator|pseudo or virtual terminal]] has been closed.<ref name="linux-signal7">{{cite web |url=https://www.kernel.org/doc/man-pages/online/pages/man7/signal.7.html|title=signal(7) |work=[[Linux Programmer's Manual]] (version 3.22)|author=Michael Kerrisk | date=25 July 2009|publisher=The Linux Kernel Archives|access-date=23 September 2009}}</ref> Many [[daemon (computing)|daemons]] (who have no controlling terminal) interpret receipt of this signal as a request to reload their configuration files and flush/reopen their logfiles instead of exiting.<ref>{{cite web|title=perlipc(1)|url=https://perldoc.perl.org/perlipc.html#Handling-the-SIGHUP-Signal-in-Daemons|work=Perl Programmers Reference Guide, version 5.18|publisher=perldoc.perl.org - Official documentation for the Perl programming language|access-date=21 September 2013}}</ref> [[nohup]] is a command to make a command ignore the signal. ; {{mono|{{vanchor|SIGILL}}}} : The SIGILL signal is sent to a process when it attempts to execute an '''illegal''', malformed, unknown, or privileged [[instruction (computer science)|instruction]]. ; {{mono|{{vanchor|SIGINT}}}} : The SIGINT signal is sent to a process by its controlling terminal when a user wishes to '''interrupt''' the process. This is typically initiated by pressing [[Control-C|{{keypress|Ctrl|C}}]], but on some systems, the "[[Delete key|delete]]" character or "[[break key|break]]" key can be used.<ref>{{cite web | url=https://www.cons.org/cracauer/sigint.html | title=Proper handling of SIGINT and SIGQUIT | access-date=6 October 2012}}</ref> ; {{mono|{{vanchor|SIGKILL}}}} : The SIGKILL signal is sent to a process to cause it to terminate immediately ('''kill'''). In contrast to SIGTERM and SIGINT, this signal cannot be caught or ignored, and the receiving process cannot perform any clean-up upon receiving this signal. The following exceptions apply: :* [[Zombie process]]es cannot be killed since they are already dead and waiting for their parent processes to reap them. :* Processes that are in the blocked state will not die until they wake up again. :* The ''[[init]]'' process is special: It does not get signals that it does not want to handle, and thus it can ignore SIGKILL.<ref>https://manpages.ubuntu.com/manpages/zesty/man2/kill.2.html {{Webarchive|url=https://web.archive.org/web/20180128103316/https://manpages.ubuntu.com/manpages/zesty/man2/kill.2.html |date=28 January 2018 }} section NOTES</ref> An exception from this rule is while init is [[ptrace]]d on Linux.<ref>{{cite web|url=https://stackoverflow.com/a/21031583|title=SIGKILL init process (PID 1)|website=Stack Overflow}}</ref><ref>{{cite web|url=https://unix.stackexchange.com/a/308429|title=Can root kill init process?|website=Unix & Linux Stack Exchange}}</ref> :* An [[uninterruptible sleep|uninterruptibly sleeping]] process may not terminate (and free its resources) even when sent SIGKILL. This is one of the few cases in which a UNIX system may have to be rebooted to solve a temporary software problem. :SIGKILL is used as a last resort when terminating processes in most system [[shutdown (computing)|shutdown]] procedures if it does not voluntarily exit in response to SIGTERM. To speed the computer shutdown procedure, Mac OS X 10.6, aka [[Mac OS X Snow Leopard|Snow Leopard]], will send SIGKILL to applications that have marked themselves "clean" resulting in faster shutdown times with, presumably, no ill effects.<ref>{{cite web | url = https://developer.apple.com/mac/library/releasenotes/MacOSX/WhatsNewInOSX/Articles/MacOSX10_6.html#//apple_ref/doc/uid/TP40008898-SW22 | title = Mac Dev Center: What's New in Mac OS X: Mac OS X v10.6 | date = 2009-08-28 | access-date =18 November 2017}}</ref> The command {{code|killall -9}} has a similar, while dangerous effect, when executed e.g. in Linux; it does not let programs save unsaved data. It has other options, and with none, uses the safer SIGTERM signal. ; {{mono|{{vanchor|SIGPIPE}}}} : The SIGPIPE signal is sent to a process when it attempts to write to a [[Pipeline (Unix)|pipe]] without a process connected to the other end. ; {{mono|{{vanchor|SIGPOLL}}}} : The SIGPOLL signal is sent when an event occurred on an explicitly watched file descriptor.<ref>{{cite web | title=ioctl - controls a STREAM device | work=[[POSIX]] system call specification | publisher=[[The Open Group]] | url=https://pubs.opengroup.org/onlinepubs/9699919799/functions/ioctl.html | access-date=19 June 2015}}</ref> Using it effectively leads to making [[asynchronous I/O]] requests since the kernel will '''poll''' the descriptor in place of the caller. It provides an alternative to active [[Polling (computer science)|polling]]. ; {{mono|{{vanchor|SIGRTMIN}}}} to {{mono|{{vanchor|SIGRTMAX}}}} : The SIGRTMIN to SIGRTMAX signals are intended to be used for user-defined purposes. They are '''real-time''' signals. ; {{mono|{{vanchor|SIGQUIT}}}} : The SIGQUIT signal is sent to a process by its controlling terminal when the user requests that the process '''quit''' and perform a [[core dump]]. ; {{mono|{{vanchor|SIGSEGV}}}} : The [[SIGSEGV]] signal is sent to a process when it makes an invalid virtual memory reference, or [[segmentation fault]], i.e. when it performs a '''seg'''mentation '''v'''iolation.<ref>{{Cite web|url=https://support.microfocus.com/kb/doc.php?id=7001662|title=What is a "segmentation violation"?|website=support.microfocus.com|access-date=2018-11-22}}</ref> ; {{mono|{{vanchor|SIGSTOP}}}} : The [[SIGSTOP]] signal instructs the operating system to '''stop''' a process for later resumption. ; {{mono|{{vanchor|SIGSYS}}}} : The SIGSYS signal is sent to a process when it passes a bad argument to a [[system call]]. In practice, this kind of signal is rarely encountered since applications rely on libraries (e.g. [[C standard library|libc]]) to make the call for them. SIGSYS can be received by applications violating the Linux [[Seccomp]] security rules configured to restrict them. SIGSYS can also be used to emulate foreign system calls, e.g. emulate Windows system calls on Linux.<ref>{{Cite web|title=Syscall User Dispatch – The Linux Kernel documentation|url=https://www.kernel.org/doc/html/latest/admin-guide/syscall-user-dispatch.html|access-date=2021-02-11|website=kernel.org}}</ref> ; {{mono|{{vanchor|SIGTERM}}}} : The SIGTERM signal is sent to a process to request its '''termination'''. Unlike the SIGKILL signal, it can be caught and interpreted or ignored by the process. This allows the process to perform nice termination releasing resources and saving state if appropriate. SIGINT is nearly identical to SIGTERM. ; {{mono|{{vanchor|SIGTSTP}}}} : The [[SIGTSTP]] signal is sent to a process by its controlling '''terminal''' to request it to '''stop''' ('''t'''erminal '''st'''o'''p'''). It is commonly initiated by the user pressing [[Ctrl-Z|{{keypress|Ctrl|Z}}]]. Unlike SIGSTOP, the process can register a signal handler for, or ignore, the signal. ; {{mono|{{vanchor|SIGTTIN}}}} and {{mono|{{vanchor|SIGTTOU}}}} : The [[SIGTTIN]] and [[SIGTTOU]] signals are sent to a process when it attempts to read '''in''' or write '''out''' respectively from the [[teletypewriter|'''tty''']] while in the [[Background process|background]]. Typically, these signals are received only by processes under [[job control (Unix)|job control]]; [[daemon (computing)|daemons]] do not have controlling terminals and, therefore, should never receive these signals. ; {{mono|{{vanchor|SIGTRAP}}}} : The SIGTRAP signal is sent to a process when an exception (or '''trap''') occurs: a condition that a [[debugger]] has requested to be informed of{{snd}} for example, when a particular [[subroutine|function]] is executed, or when a particular [[variable (computer science)|variable]] changes value. ; {{mono|{{vanchor|SIGURG}}}} : The [[SIGURG]] signal is sent to a process when a [[Berkeley sockets|socket]] has '''urgent''' or [[out-of-band data]] available to read. ; {{mono|{{vanchor|SIGUSR1}}}} and {{mono|{{vanchor|SIGUSR2}}}} : The SIGUSR1 and SIGUSR2 signals are sent to a process to indicate '''user-defined conditions'''. ; {{mono|{{vanchor|SIGXCPU}}}} : The SIGXCPU signal is sent to a process when it has used up the '''[[Central processing unit|CPU]]''' for a duration that '''exceeds''' a certain predetermined user-settable value.<ref name="setrlimit_posix_spec">{{cite web | title = getrlimit, setrlimit - control maximum resource consumption | work=[[POSIX]] system call specification | publisher=[[The Open Group]] | url=https://pubs.opengroup.org/onlinepubs/009695399/functions/getrlimit.html | access-date = 10 September 2009}}</ref> The arrival of a SIGXCPU signal provides the receiving process a chance to quickly save any intermediate results and to exit gracefully, before it is terminated by the operating system using the SIGKILL signal. ; {{mono|{{vanchor|SIGXFSZ}}}} : The SIGXFSZ signal is sent to a process when it grows a '''file''' that '''exceeds''' the maximum allowed '''size'''. ; {{mono|{{vanchor|SIGWINCH}}}} : The SIGWINCH signal is sent to a process when its controlling terminal changes its size (a '''win'''dow '''ch'''ange).<ref>{{cite web |url=http://austingroupbugs.net/view.php?id=1151 |title= 0001151: Introduce new signal SIGWINCH and functions tcsetsize(), tcgetsize() to get/set terminal window size |last=Clausecker |first=Robert |date=2017-06-19 |website=Austin Group Defect Tracker |publisher=[[Austin Group]] |access-date=2017-10-12 |quote=Accepted As Marked}}</ref> ==Miscellaneous signals== The following signals are not specified in the [[POSIX]] specification. They are, however, sometimes used on various systems. ; {{mono|{{vanchor|SIGEMT}}}} : The SIGEMT signal is sent to a process when an '''em'''ulator '''t'''rap occurs. While an '''[[emulator]]''' usually means software that executes other programs, in this case it means a program executed a [[supervisor call]] instruction (EMT was the instruction for this purpose on the [[Digital Equipment Corporation|DEC]] [[PDP-11]] series of computers.) ; {{mono|{{vanchor|SIGINFO}}}} : The SIGINFO signal is sent to a process when a status ('''info''') request is received from the controlling terminal. ; {{mono|{{vanchor|SIGPWR}}}} : The SIGPWR signal is sent to a process when the system experiences a '''[[power failure]]'''. ; {{mono|{{vanchor|SIGLOST}}}} : The SIGLOST signal is sent to a process when a file lock is '''lost'''. ; {{mono|{{vanchor|SIGSTKFLT}}}} : The SIGSTKFLT signal is sent to a process when the coprocessor experiences a '''st'''ac'''k''' '''f'''au'''lt''' (i.e. popping when the stack is empty or pushing when it is full).<ref name="courier-mta.org">{{Cite web|url=https://manpages.courier-mta.org/htmlman7/signal.7.html|title=signal(7) — Linux manual pages|website=manpages.courier-mta.org|access-date=2018-11-22}}</ref> It is defined by, but not used on Linux, where a [[x87]] coprocessor stack fault will generate SIGFPE instead.<ref>{{cite web|url=https://stackoverflow.com/questions/9332864/linux-3-0-x86-64-when-is-sigstkflt-raised#comment51557777_9333099|title=Linux 3.0 x86_64: When is SIGSTKFLT raised?|website=Stack Overflow}}</ref> ; {{mono|{{vanchor|SIGUNUSED}}}} : The SIGUNUSED signal is sent to a process when a system call with an '''unused''' system call number is made. It is synonymous with SIGSYS on most architectures.<ref name="courier-mta.org"/> ; {{mono|{{vanchor|SIGCLD}}}} : The SIGCLD signal is synonymous with SIGCHLD.<ref name="courier-mta.org"/> ==See also== * [[Asynchronous procedure call]] (APC) * [[C signal handling]] ==References== {{reflist}} * {{cite book |title=Advanced Programming in the UNIX® Environment |last=Stevens |first=W. Richard |author-link=W. Richard Stevens |year=1992 |publisher=Addison Wesley |location=Reading, Massachusetts |isbn=0-201-56317-7 |url=https://archive.org/details/advancedprogramm00stev |ref=Ste92 |url-access=registration }} * {{cite web | publisher=[[The Open Group]] | title=The ®Open Group Base Specifications Issue 8, IEEE Std 1003.1™-2024 Edition | url=https://pubs.opengroup.org/onlinepubs/9799919799/ | access-date=2025-03-02}} ==External links== * [https://people.cs.pitt.edu/~alanjawi/cs449/code/shell/UnixSignals.htm Unix Signals Table, Ali Alanjawi, University of Pittsburgh] * [http://man7.org/linux/man-pages/man7/signal.7.html Man7.org Signal Man Page] * Introduction To Unix Signals Programming {{webarchive |url=https://web.archive.org/web/20130926005901/http://users.actcom.co.il/~choo/lupg/tutorials/signals/signals-programming.html |date=26 September 2013 |title=Introduction To Unix Signals Programming }} * [https://www.linuxprogrammingblog.com/all-about-linux-signals Another Introduction to Unix Signals Programming] (blog post, 2009) * {{usurped|1=[https://web.archive.org/web/20230413214743/http://www.enderunix.org/docs/signals.pdf UNIX and Reliable POSIX Signals]}} by Baris Simsek (stored by the [[Internet Archive]]) * [https://www.openbsd.org/papers/opencon04/index.html Signal Handlers] by Henning Brauer {{Inter-process communication}} [[Category:Inter-process communication]] [[Category:Control flow]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:About
(
edit
)
Template:Cite book
(
edit
)
Template:Cite tech report
(
edit
)
Template:Cite web
(
edit
)
Template:Cn
(
edit
)
Template:Code
(
edit
)
Template:Dropped
(
edit
)
Template:Inter-process communication
(
edit
)
Template:Keypress
(
edit
)
Template:Mono
(
edit
)
Template:More citations needed
(
edit
)
Template:N/A
(
edit
)
Template:N/a
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Template:Snd
(
edit
)
Template:Terminated
(
edit
)
Template:Tt
(
edit
)
Template:Use dmy dates
(
edit
)
Template:Usurped
(
edit
)
Template:Webarchive
(
edit
)