In that year, I learned Linux C-signal details step by step ~

Source: Internet
Author: User

This series of articles written by muge0913, reproduced please note the Source: http://blog.csdn.net/muge0913/article/details/7322710


Signal and Its Introduction

A signal is a process communication method that is used to process asynchronous events. Signal implementation is a soft interrupt. It is sent as a running process and has been notified of an event in the process.

1) The sighup signal is sent at the end of the user terminal connection (normal or abnormal), usually in the terminal's control

When the process ends, all jobs in the same session are notified, and they are no longer associated with the control terminal.

2) SIGINT program termination (Interrupt) signal, usually from the terminal to issue interrupt commands such as Ctrl + C or delete key

3) sigquit is similar to SIGINT, but it is controlled by the quit character (usually Ctrl + \).

The core file is generated when sigquit exits. In this sense, it is similar to a program error signal.

4) sigill executes invalid commands. This is usually because the executable file itself has an error or an attempt to execute

Data Segment. This signal may also be generated when the stack overflows.

5) The sigtrap tracking trap signal is generated by the breakpoint instruction or other trap instruction and used by the debugger.

6) The signal generated when SIGABRT calls abort may lead to abnormal Process Termination.

6) sigiot Io error signal.

7) signal generated when the sigbus system bus is wrong, illegal address, including memory address alignment error. eg: access a four-character long

But its address is not a multiple of 4.

(8) sigfpe is triggered when a fatal arithmetic operation error occurs. This includes not only floating point operation errors, but also overflow.

An error occurs in all other arithmetic operations, such as 0 in the output and devisor.

9) sigkill can terminate any process signal, which can only be sent by the Administrator and will not be captured or ignored.

10) SIGUSR1 is reserved for users and can be customized in applications.

11) SIGSEGV attempts to access the memory not allocated to itself, or write data to the memory address that has no write permission, illegally using the memory address signal.

12) sigusr2 is reserved for users.

13) sigpipe signal generated when a process completes reading the pipeline and then writes it.

14) sigalrm timing signal, which is generated when the time specified by the alarm function is terminated.

15) The sigterm program terminate signal. Unlike sigkill, this signal can be blocked and processed. It is usually used to require the program to exit normally. The shell command kill generates this signal by default.

17) this signal is generated when the sigchld sub-process ends or is interrupted. The parent process receives this signal. Through this signal, the parent process can know the running status of the sub-process. However, this signal is ignored in most cases.

18) sigcont allows a stopped process to continue execution. This signal cannot be blocked.

19) sigstop stop (stopped) process execution. Note the differences between it and terminate and interrupt:

This process has not ended, but is paused. This signal cannot be blocked, processed, or ignored.

20) sigtstp stops the process, but the signal can be processed and ignored.

(Usually Ctrl-z) sends this signal

21) sigttin: the signal generated by the drive interruption when the background job reads data from the user terminal. When the process that reads data blocks or ignores this signal, or the process group where the process that reads the data is located is an isolated process group, the signal does not occur and a read error occurs. Errno is set to ETO

22) sigttou is similar to sigttin. When a background job needs to read data from a user terminal, the drive signal is interrupted. When the process that reads data blocks or ignores this signal, or the process group where the process that reads the data is located is an isolated process group, the signal does not occur and a read error occurs. Errno is set to Eto. The only difference is that the process can select background write.

23) The message sent when an emergency occurs on the sigurg socket.

24) The sigxcpu exceeds the CPU time limit. This limit can be read/changed by getrlimit/setrlimit.

25) sigxfsz exceeds the file size resource limit.

26) sigvtalrm virtual clock signal. Similar to sigalrm, the CPU time occupied by the process is calculated.

27) sigprof is similar to sigalrm/sigvtalrm, but includes the CPU time used by the process and the system call time.

28) it is issued when the sigwinch window size is changed.

29) The sigio file descriptor is ready for input/output operations.

30) sigpwr power failure signal.

31) signal generated when a real-time hardware error occurs in sigemt.

 

There are two signals to stop the process: sigterm and sigkill. Sigterm is relatively friendly, and processes can capture this signal and close the program as needed. Before closing the program, you can end the opened record file and complete ongoing tasks. In some cases, if the process is running and cannot be interrupted, the process can ignore this sigterm signal.

 

Processes cannot ignore sigkill signals. This is a signal "I don't care what you are doing, stop immediately. If you send a sigkill signal to the process, Linux stops the process.

 

Note: There are six signals called Job signals, sigchld, sigcont, sigstop, sigstp, sigttni, sigttou. these signals are used to coordinate and organize various processes, that is, to achieve the so-called job control. Normally, the user does not need to process these signals, and the shell will automatically process these signals. Signals affect each other. When a process receives a sigcont signal, the sigstop, sigstp, sigttin, and sigttou signals suspended by the system will become invalid. When the same process receives sigstop, sigstp, sigttin, and sigttou, sigcont becomes invalid.

 

 

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.