Linux under C Programming: signal specific meaning explanation

Source: Internet
Author: User
Tags arithmetic exit delete key file size resource linux

Signal and its introduction

A signal is a process communication method that applies to the processing of asynchronous events. The realization of signal is a kind of soft interrupt. It is sent as a running process, and a process has been told that an event has occurred.

1 Sighup This signal at the end of the user terminal connection (normal or abnormal), usually at the end of the control process, notify the same session of each job, when they are no longer associated with the control terminal.

2 SIGINT program termination (interrupt) signal, usually from the terminal issued interrupt instructions such as CTRL + C or DELETE key

3) Sigquit and SIGINT are similar, but are controlled by the Quit character (usually ctrl+\). The process produces a core file when it receives a sigquit exit, similar to a bug signal in this sense.

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

5 Sigtrap tracking trap signal, which is produced by breakpoint instruction or other trap instruction. Used by debugger.

6) The signal generated when SIGABRT calls abort will cause the process to end abnormally.

6) Sigiot IO error signal.

7 Sigbus system bus error, illegal address, including memory address alignment (alignment) error. Eg: accesses an integer of four word length, but its address is not a multiple of 4.

8) Sigfpe in the event of a fatal arithmetic error. Not only floating-point arithmetic errors, but also all other arithmetic errors including overflow and divisor 0.

9 SIGKILL can terminate any process signal, can only be issued by the Administrator, the signal will not be caught and ignored.

SIGUSR1 is left to the user and can be defined by the user in the application.

SIGSEGV attempts to access memory that is not assigned to itself, or attempts to write data to a memory address that does not have write access, and uses the memory address signal illegally.

SIGUSR2 left to the user to use

Sigpipe the signal that occurs when a process finishes writing a pipe after it has been read.

SIGALRM clock timing signal, the signal generated by the time when the alarm function is set to terminate.

Sigterm program End (terminate) signal, unlike Sigkill, the signal can be blocked and processed. It is usually used to require the program to exit normally. The shell command kill defaults to produce this signal.

SIGCHLD occurs when the child process ends or interrupts, and the parent process receives this signal. Through this signal the parent process can know the operation of the child process. But in most cases this signal will be ignored.

Sigcont let a stop (stopped) process continue. This signal cannot be blocked.

The execution of the SIGSTOP stop (stopped) process. Notice the difference between it and terminate and interrupt: The process is not finished, but it is paused. This signal cannot be blocked, processed or ignored.

SIGTSTP stops the process from running, but the signal can be processed and ignored. The user types the Susp word characters (usually ctrl-z) to send this signal

Sigttin when the background job to read data from the user terminal, interrupt the drive generated signal. The signal does not occur and a read error occurs when the process that reads the data blocks or ignores the signal, or when the process group that reads the data is an orphaned group of processes. Errno was set to Eto

Sigttou similar to Sigttin, when the background job to read data from the user terminal, interrupt the drive generated signal. The signal does not occur and a read error occurs when the process that reads the data blocks or ignores the signal, or when the process group that reads the data is an orphaned group of processes. Errno was set up as Eto. The only difference is that the process can choose to write background.

The emergency situation on the Sigurg socket is the message sent.

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

Sigxfsz exceeds the file size resource limit.

SIGVTALRM virtual clock signal. Similar to SIGALRM, but calculates the CPU time that the process consumes.

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

Sigwinch when the window size changes.

Sigio file descriptor is ready to start an input/output operation.

SIGPWR power failure failure signal.

SIGEMT the signal generated when a real-time hardware error occurs.

There are two signals that can stop the process: Sigterm and Sigkill. Sigterm is more friendly, the process can capture this signal and close the program according to your needs. Before you close the program, you can end the open record file and complete the task you are doing. In some cases, if the process is working and cannot be interrupted, the process can ignore the sigterm signal.

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

Note: There are six signals known as job signals, Sigchld,sigcont,sigstop,sigstp,sigttni,sigttou. These signals are used to coordinate and organize processes, that is, to achieve so-called job control. Typically, the user does not need to process these signals, and the shell automatically processes the signals. The signal is interacting with each other, and when the process receives the sigcont signal, the Sigstop,sigstp,sigttin,sigttou suspended by the system will fail. When the process receives the Sigstop,sigstp,sigttin,sigttou, the Sigcont will fail.

View a full set of articles: Http://www.bianceng.cn/Programming/C/201212/34807.htm

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.