linux-Signal Explanation

Source: Internet
Author: User
Tags arithmetic terminates

1.all the signals supported by Linux :

Kill -L
 1) SIGHUP2) SIGINT3) Sigquit4) Sigill5) SIGTRAP6) SIGABRT7) Sigbus8) SIGFPE9) SIGKILLTen) SIGUSR1 One) SIGSEGV A) SIGUSR2 -) Sigpipe -) SIGALRM the) SIGTERM -) Sigstkflt -) SIGCHLD -) Sigcont +) SIGSTOP -) SIGTSTP +) Sigttin A) Sigttou at) Sigurg -) sigxcpu -) Sigxfsz -) SIGVTALRM -) sigprof -) Sigwinch in) SIGIO -) SIGPWR to) Sigsys the) sigrtmin *) sigrtmin+1     $) sigrtmin+2    Panax Notoginseng) sigrtmin+3 -) sigrtmin+4     the) sigrtmin+5     +) sigrtmin+6     A) sigrtmin+7     the) sigrtmin+8 +) sigrtmin+9     -) sigrtmin+Ten     $) sigrtmin+ One     $) sigrtmin+ A     -) sigrtmin+ - -) sigrtmin+ -     the) sigrtmin+ the     -) sigrtmax- -    Wuyi) sigrtmax- -     the) sigrtmax- A -) sigrtmax- One     Wu) sigrtmax-Ten     -) sigrtmax-9     About) sigrtmax-8     $) sigrtmax-7 -) sigrtmax-6     -) sigrtmax-5     -) sigrtmax-4     A) sigrtmax-3     +) sigrtmax-2 the) sigrtmax-1     -) Sigrtmax

2. signal description and Default processing method :

signal Value The default processing action causes the signal to be signaled sighup1A terminal hangs or controls process termination (hang up) SIGINT2A Keyboard interrupt (such as the break key is pressed) (interrupt) Sigquit3C Keyboard Exit key is pressed (quit) Sigill4C Illegal Instruction (illegal) SIGABRT6C by Abort (3) exit instruction (abort) issued by SIGFPE8C Floating-point exception Sigkill9AEF kill Signal SIGSEGV OneC Invalid memory reference Sigpipe -a pipeline rupture: write a pipe without a read port Sigalrm -A by Alarm (2) signals emitted by sigterm theA termination Signal SIGUSR1 -,Ten, -A user-defined signal 1SIGUSR2 to, A, -A user-defined signal 2SIGCHLD -, -, -B Sub-process end signal Sigcont +, -, -process continues (a process that has been stopped) SIGSTOP -, +, atDEF terminating process SIGTSTP -, -, -D Control Terminal (TTY) press the stop button Sigttin +, +, -D Background process attempts to read Sigttou from the control terminal A, A, -D The background process attempts to write from the control terminal the letter meaning of an item is as follows a default action is to terminate process B default action is to ignore this signal, discard the signal, do not do the C default action is to terminate the process and kernel image dump (dump core), Kernel image dump refers to the process data in the memory of the image and part of the process in the kernel structure to dump into the file system, and the process exits execution, the benefit is to provide programmers with the convenience, so that they can get the process at the time of execution of data values, allowing them to determine the cause of the dump, And can debug their programs. D The default action is to stop the process, after entering the stop condition can be restarted, generally in the process of debugging (for example, Ptrace system call) E signal can not be captured F signal can not be ignored

3. process-to-signal processing in three ways

1) ignoring (ignore) signal, the signal is cleared, the process itself does not take any special action

2) default operation. Each signal pair should have a certain default action. For example the above sigcont is used to continue the process.

3) Custom actions. Also called the Get (catch) signal. The action that corresponds to the signal is preset in the execution process.

4. detailed description of signal less than sigrtmin

1SIGHUP This signal is issued at the end of the user terminal connection (normal or abnormal), usually at the end of the control process of the terminal to notify the same session of the various jobs, when 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, type intr characters in the user (usually Ctrl - C) to notify the foreground process group to terminate the process. 3Sigquit and SIGINT are similar, but by the quit character (usually Ctrl -/) to control. 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. 5Sigtrap is generated by a breakpoint instruction or other trap instruction. Used by debugger. 6SIGABRT calls 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). 8The 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. 9Sigkill is used to immediately end the run 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. Ten) SIGUSR1 left to the user to use OneSIGSEGV tries to access memory that is not assigned to itself, or attempts to write data to a memory address that does not have write permissions. A) SIGUSR2 left to the user to use -) Sigpipe pipe rupture. 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 to calculate the actual time or clock time. The alarm function uses this signal. theThe 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.  -The parent process receives this signal when the SIGCHLD child process ends. If the parent process does not process the signal, there is no wait (waitChild process , although the child process terminates, but also occupies the table entry in the kernel process table, the child process is called the 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, to re-display the prompt +) 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. -The SIGTSTP stops the process from running, but the signal can be processed and ignored. When a user types Susp characters (usually Ctrl - Z) Send this signal +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. ASigttou is similar to Sigttin, but is received when writing a terminal (or modifying terminal mode). at) Sigurg has"Emergency"Data or out-of-band data is generated when the socket is reached. -Sigxcpu exceeds the CPU time resource limit. This restriction can be made by Getrlimit/setrlimit to read/change.  -Sigxfsz When the process attempts to enlarge the file so that it exceeds the file size resource limit.  -) sigvtalrm the virtual clock signal. is similar to SIGALRM, but calculates the CPU time that is consumed by the process. -) sigprof similar to SIGALRM/SIGVTALRM, but includes the CPU time used by the process and the time of the system call. -sigwinch The window size is changed. in) The Sigio file descriptor is ready to start the input/output operation. -) sigpwrpower Failure to) Sigsys an illegal system call. In the signals listed above, the program is not able to capture, block or ignore the signal is: Sigkill,sigstop can not be restored to the default action signal is: Sigill,sigtrap default causes the process to abort the signal is: SIGABRT,SIGBUS,SIGFPE, Sigill,sigiot,sigquit,sigsegv,sigtrap,sigxcpu,sigxfsz default causes the process to exit the signal is: sigalrm,sighup,sigint,sigkill,sigpipe, SIGPOLL,SIGPROF,SIGSYS,SIGTERM,SIGUSR1,SIGUSR2,SIGVTALRM default causes the process to stop the signal is: Sigstop,sigtstp,sigttin, Sigttou The default process ignores the signals are: Sigchld,sigpwr,sigurg,sigwinch

5. using the signal instance in the shell

Ping localhost

At this point we can pass the SIGTSTP to the process via CTRL + Z. Show in Shell

[1]+  Stopped                 ping localhost

We use $ps to query the PID of the ping process (PID is the room number of the ping process), which is 27397 in my machine

We can send a signal to a process in the shell through the $kill command:

kill -sigcont  27397

Sigcont indicates that the suspended process continues execution

linux-Signal Explanation

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: 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.