Linux Signals: Difference between revisions
No edit summary |
|||
(33 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
=Internal= | =Internal= | ||
* [[Linux | * [[Linux General Concepts#Signals|Linux General Concepts]] | ||
=Overview= | |||
Signals are numeric messages sent to running applications by the operating system, other applications, or the user. The signals are sent asynchronously, and allows the kernel to communicate asynchronously with processes. A signal is managed in a cascading manner. It's sent to the application or script, then if the application doesn't have a specific handler, it's pushed back to the shell or operating system. Some signals can't be managed within individual apps: for example SIGKILL is caught by the operating system and immediately kills the running application. For the rest of the signals, processes may or may not intercept the signals. | |||
To send a specific signal to a process: | |||
kill -<''signal-value''> <''pid''> | |||
kill -2 3345 | |||
=Signals= | =Signals= | ||
Line 13: | Line 23: | ||
POSIX signal. Hangup. | POSIX signal. Hangup. | ||
Hangup is the signal that is sent to the process when the terminal closes on a foreground process. | Hangup is the signal that is sent to the process when the terminal closes on a [[Linux_General_Concepts#Foreground_Process|foreground process]]. The default action the process should respond with is "terminate". Programs like [[Nohup#Overview|nohup]] chose to intercept, then ignore this signal, protecting their children from termination when the [[Linux_TTY#Overview|TTY]] is disconnected. | ||
Also see: | Also see: | ||
<blockquote style="background-color: #f9f9f9; border: solid thin lightgrey;"> | <blockquote style="background-color: #f9f9f9; border: solid thin lightgrey;"> | ||
:[[Nohup#Overview|nohup]] | :[[Nohup#Overview|nohup]] | ||
: | |||
:[[Httpd_Concepts#Restart_Now|httpd Restart Now]] | |||
</blockquote> | </blockquote> | ||
==SIGINT (2)== | |||
Sends the process an interrupt. Guaranteed to be present on all systems. The default action a process should respond with is "terminate". | |||
bash sends SIGINT to the process running in [[Bash_Concepts#Foreground_Process|foreground]] when Ctrl-C is pressed. | |||
==SIGQUIT (3)== | |||
The default action is "core dump". When sent into a Java Virtual Machine, Will trigger the JVM to generate a [[Java_Threads#Thread_Dump|thread dump]]. | |||
==SIGILL (4)== | ==SIGILL (4)== | ||
The SIGILL signal is sent to a process when it attempts to execute an illegal, malformed, unknown, or privileged instruction. | |||
==SIGTRAP (5)== | ==SIGTRAP (5)== | ||
Line 41: | Line 56: | ||
==SIGUSR1 (10)== | ==SIGUSR1 (10)== | ||
[[Httpd_Concepts#Graceful_Restart|httpd Graceful Restart]] | Also see: | ||
<blockquote style="background-color: #f9f9f9; border: solid thin lightgrey;"> | |||
:[[Httpd_Concepts#Graceful_Restart|httpd Graceful Restart]] | |||
</blockquote> | |||
==SIGSEGV (11)== | ==SIGSEGV (11)== | ||
Line 48: | Line 66: | ||
==SIGPIPE (13)== | ==SIGPIPE (13)== | ||
The default action is "terminate". The kernel sends SIGPIPE to any process which tries to write to a pipe with no readers. | |||
==SIGALRM (14)== | ==SIGALRM (14)== | ||
Line 53: | Line 73: | ||
==SIGTERM (15)== | ==SIGTERM (15)== | ||
[[Httpd_Concepts#Stop_Now|httpd Stop Now]] | Also see: | ||
<blockquote style="background-color: #f9f9f9; border: solid thin lightgrey;"> | |||
:[[Httpd_Concepts#Stop_Now|httpd Stop Now]] | |||
</blockquote> | |||
==SIGSTKFLT (16)== | ==SIGSTKFLT (16)== | ||
==SIGCHLD (17)== | ==SIGCHLD (17)== | ||
The default action is "ignore". | |||
When a process dies or changes state, the kernel sends a SIGCHLD to the parent process. The [[Linux_General_Concepts#Session_Leader|session leader (shell)]] keeps track of its jobs using this signal. | |||
==SIGCONT (18)== | ==SIGCONT (18)== | ||
POSIX. Continue executing, if stopped. | POSIX. Default action is "wake up". Continue executing, if stopped. This is the signal sent explicitly by the shell to a stopped application when the user invokes the [[bash fg|fg]] command. | ||
Also see: | Also see: | ||
Line 71: | Line 98: | ||
==SIGSTOP (19)== | ==SIGSTOP (19)== | ||
POSIX. | POSIX. The default action is "suspend". It means stop executing. The signal cannot be caught or ignored, so it will unconditionally suspend the recipient. | ||
Also see: | Also see: | ||
{{Internal|JGroups Troubleshooting Techniques#Suspend_JVM_Execution|Suspending JVM Execution}} | |||
==SIGTSTP (20)== | ==SIGTSTP (20)== | ||
The default action is "suspend". Suspends a process executing in foreground. bash sends SIGTSTP to the process running in [[Bash_Concepts#Foreground_Process|foreground]] when Ctrl-Z is pressed. | |||
==SIGTTIN (21)== | ==SIGTTIN (21)== | ||
Line 96: | Line 123: | ||
==SIGWINCH (28)== | ==SIGWINCH (28)== | ||
The [[TTY#TTY_Driver|TTY device]] keeps track of the terminal size. When this information is updated, the TTY device sends SIGWINCH to the foreground job. Well-behaved interactive applications, such as editors, should react upon this, fetch the new terminal size from the TTY device and re-render themselves. | |||
Also see: | |||
{{Internal|Httpd_Concepts#Graceful_Stop|httpd Graceful Stop}} | |||
==SIGIO (29)== | ==SIGIO (29)== | ||
Line 104: | Line 137: | ||
==SIGRTMIN (34)== | ==SIGRTMIN (34)== | ||
=Signals in Go= | =Signals in Go= | ||
Line 113: | Line 143: | ||
:[[Go Signals|Signals in Go]] | :[[Go Signals|Signals in Go]] | ||
</blockquote> | </blockquote> | ||
=Signals and bash= | |||
{{Internal|Handling_Signals_in_bash|Handling Signals in bash}} |
Latest revision as of 03:36, 3 May 2018
External
Internal
Overview
Signals are numeric messages sent to running applications by the operating system, other applications, or the user. The signals are sent asynchronously, and allows the kernel to communicate asynchronously with processes. A signal is managed in a cascading manner. It's sent to the application or script, then if the application doesn't have a specific handler, it's pushed back to the shell or operating system. Some signals can't be managed within individual apps: for example SIGKILL is caught by the operating system and immediately kills the running application. For the rest of the signals, processes may or may not intercept the signals.
To send a specific signal to a process:
kill -<signal-value> <pid>
kill -2 3345
Signals
SIGHUP (1)
POSIX signal. Hangup.
Hangup is the signal that is sent to the process when the terminal closes on a foreground process. The default action the process should respond with is "terminate". Programs like nohup chose to intercept, then ignore this signal, protecting their children from termination when the TTY is disconnected.
Also see:
SIGINT (2)
Sends the process an interrupt. Guaranteed to be present on all systems. The default action a process should respond with is "terminate".
bash sends SIGINT to the process running in foreground when Ctrl-C is pressed.
SIGQUIT (3)
The default action is "core dump". When sent into a Java Virtual Machine, Will trigger the JVM to generate a thread dump.
SIGILL (4)
The SIGILL signal is sent to a process when it attempts to execute an illegal, malformed, unknown, or privileged instruction.
SIGTRAP (5)
SIGFPE (8)
SIGKILL (9)
POSIX. Kill the process. The signal cannot be caught or ignored. Guaranteed to be present on all systems.
SIGUSR1 (10)
Also see:
SIGSEGV (11)
SIGUSR2 (12)
SIGPIPE (13)
The default action is "terminate". The kernel sends SIGPIPE to any process which tries to write to a pipe with no readers.
SIGALRM (14)
SIGTERM (15)
Also see:
SIGSTKFLT (16)
SIGCHLD (17)
The default action is "ignore".
When a process dies or changes state, the kernel sends a SIGCHLD to the parent process. The session leader (shell) keeps track of its jobs using this signal.
SIGCONT (18)
POSIX. Default action is "wake up". Continue executing, if stopped. This is the signal sent explicitly by the shell to a stopped application when the user invokes the fg command.
Also see:
SIGSTOP (19)
POSIX. The default action is "suspend". It means stop executing. The signal cannot be caught or ignored, so it will unconditionally suspend the recipient.
Also see:
SIGTSTP (20)
The default action is "suspend". Suspends a process executing in foreground. bash sends SIGTSTP to the process running in foreground when Ctrl-Z is pressed.
SIGTTIN (21)
SIGTTOU (22)
SIGURG (23)
SIGXCPU (24)
SIGXFSZ (25)
SIGVTALRM (26)
SIGPROF (27)
SIGWINCH (28)
The TTY device keeps track of the terminal size. When this information is updated, the TTY device sends SIGWINCH to the foreground job. Well-behaved interactive applications, such as editors, should react upon this, fetch the new terminal size from the TTY device and re-render themselves.
Also see: