LINUX Signal Concept Detailed

Source: Internet
Author: User
Tags arithmetic terminates

LINUX Signal Concept Detailed

We run the following command to see a list of supported signals from Linux:

# kill-l1)     SIGHUP 2) SIGINT 3) Sigquit 4) SIGILL5) SIGTRAP 6) SIGABRT 7) Sigbus 8) SIGFPE9) SIGKILL     (SIGUSR1) SIGSEGV) SIGUSR213) sigpipe) sigalrm) SIGTERM) SIGCHLD18 (SIGSTOP) SIGTSTP) SIGTTIN22) (Sigttou) Sigurg) sigxcpu) SIGXFSZ26 27) SIGPROF) (sigwinch) SIGIO30) SIGPWR Sigsys) sigrtmin) sigrtmin+136) SIG rtmin+3) (sigrtmin+4) sigrtmin+540) (sigrtmin+6) sigrtmin+7) sigrtmin+8) sigrtmin+944) S IGRTMIN+11) (sigrtmin+12) sigrtmin+1348) sigrtmin+14 sigrtmin+15) SIGRTMAX-14) SIGRTMAX-1352 5  3) SIGRTMAX-11 SIGRTMAX-10) SIGRTMAX-956) SIGRTMAX-8 SIGRTMAX-7) SIGRTMAX-6) SIGRTMAX-560 (SIGRTMAX-3) (SIGRTMAX-2) SIGRTMAX-164) Sigrtmax 


Signals numbered 1 ~ 31 are signals supported by traditional UNIX, are unreliable signals (not real-time), and the signals numbered 32 to 63 are later expanded, called reliable signals (real-time signals). The difference between unreliable and reliable signals is that the former does not support queueing and may cause signal loss, while the latter does not.

Below we discuss a signal with a number less than sigrtmin.

1) SIGHUP This signal is issued at the end of the user terminal connection (normal or abnormal), usually at the end of the terminal control process, notify the same session of the various jobs, then they are no longer associated with the control terminal.

When you log in to Linux, the system is assigned to a terminal (Session) of the logged-on user. All programs running at this terminal, including the foreground process group and the background process group, usually belong to this session. When the user exits the Linux login, the foreground process group and the background will receive a sighup signal to the terminal output process. The default action for this signal is to terminate the process, so the foreground process group and the process that has terminal output in the background will be aborted. However, this signal can be captured, such as wget can capture the sighup signal, and ignore it, so even if you quit the Linux login, wget can continue to download.
In addition, for daemons with terminal disengagement, this signal is used to notify it to reread the configuration file.

2) SIGINT program termination (interrupt) signal, issued when the user types Intr characters (usually ctrl-c), to notify the foreground process group to terminate the process.

3) Sigquit and SIGINT are similar, but are controlled by the Quit character (usually ctrl-/). The process generates a core file when it receives a sigquit exit, similar to a program error signal in this sense.

4) Sigill executed an illegal instruction. This is usually due to an error in the executable file itself or an attempt to execute a data segment. This signal can also be generated when a stack overflows.

5) The SIGTRAP is generated by a breakpoint instruction or other trap instruction. Used by debugger.

6) SIGABRT Call the Abort function to generate the signal.

7) Sigbus illegal address, including memory address alignment (alignment) error. For example, a four-word integer is accessed, but its address is not a multiple of 4. It differs from SIGSEGV in that the latter is triggered by illegal access to a legitimate storage address (such as Access does not belong to its own storage space or read-only storage space).

8) The SIGFPE is emitted when a fatal arithmetic operation error occurs. This includes not only floating-point arithmetic errors, but also all other arithmetic errors such as overflow and divisor 0.

9) SIGKILL is used to immediately end the operation of the program. This signal cannot be blocked, processed, or ignored. If an administrator discovers that a process is not terminating, try sending this signal.

SIGUSR1 is reserved for use by users.

One) SIGSEGV attempts to access memory that is not allocated to itself, or attempts to write data to a memory address that does not have write permissions.

SIGUSR2 is reserved for the user to use.

Sigpipe pipe burst. This signal is usually generated between interprocess communication, such as two processes with FIFO (pipeline) communication, the read pipeline is not opened or terminated unexpectedly to the pipeline to write, the writing process will receive sigpipe signal. In addition, two processes with the socket communication, the write process when the socket is written, the read process has been terminated.

SIGALRM clock timing signal, which calculates the actual time or clock time. The alarm function uses this signal.

The SIGTERM program end (terminate) signal, unlike Sigkill, is that the signal can be blocked and processed. Typically used to require the program to exit gracefully, the shell command kill generates this signal by default. If the process does not stop, we will try to Sigkill.

SIGCHLD the parent process will receive this signal at the end of the child process.

If the parent process does not process the signal and does not wait for the (wait) child process, although the child process terminates, it also occupies the table entry in the kernel process table, when the child process is called a zombie process. In this case we should avoid (the parent process either ignores the sigchild signal, or catches it, or wait for its derived child process, or the parent process terminates first, and the termination of the child process is automatically taken over by the Init process).

Sigcont let a stop (stopped) process continue execution. This signal cannot be blocked. You can use a handler to get the program to do certain work when the stopped state changes to continue. For example, display the prompt again.

SIGSTOP the execution of the Stop (stopped) process. Notice the difference between it and terminate and interrupt: The process is not over yet, just pause execution. This signal cannot be blocked, processed or ignored.

SIGTSTP stops the process from running, but the signal can be processed and ignored. This signal is emitted by the user when typing Susp characters (usually ctrl-z).

Sigttin when a background job reads data from a user terminal, all processes in that job receive a sigttin signal. By default, these processes stop executing.

Sigttou is similar to Sigttin, but is received when writing a terminal (or modifying terminal mode).

Sigurg) is generated when "emergency" data or Out-of-band data arrives at the socket.

SIGXCPU exceeds the CPU time resource limit. This restriction can be read/changed by Getrlimit/setrlimit.

Sigxfsz when a process attempts to enlarge a file so that it exceeds the file size resource limit.

() SIGVTALRM virtual clock signal. is similar to SIGALRM, but calculates the CPU time that is consumed by the process.

Sigprof is similar to SIGALRM/SIGVTALRM, but includes the CPU time used by the process and the time of the system call.

sigwinch) When the window size changes.

) The SIGIO file descriptor is ready to start the input/output operation.

SIGPWR Power failure.

) Sigsys illegal system calls.

In the signals listed above, the program can not capture, block or ignore the signal is: sigkill,sigstop
Signals that cannot be restored to the default action are: Sigill,sigtrap
The default causes the process to abort the signal is: Sigabrt,sigbus,sigfpe,sigill,sigiot,sigquit,sigsegv,sigtrap,sigxcpu,sigxfsz
The signal that causes the process to exit by default is: SIGALRM,SIGHUP,SIGINT,SIGKILL,SIGPIPE,SIGPOLL,SIGPROF,SIGSYS,SIGTERM,SIGUSR1,SIGUSR2,SIGVTALRM
The signal that causes the process to stop by default is: Sigstop,sigtstp,sigttin,sigttou
The default process ignores signals such as: Sigchld,sigpwr,sigurg,sigwinch

In addition, Sigio in SVR4 is exited, is ignored in 4.3BSD, Sigcont is continued when the process hangs, otherwise it is ignored and cannot be blocked.

This article from the "Crushlinux" blog, reproduced please contact the author!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.