Linux semaphore signal 0< turn >

Source: Internet
Author: User
Tags arithmetic posix semaphore signal handler terminates

We can use Kill-l to see all the semaphore interpretations, but we don't see the explanation for signal 0.

[[Email protected]~]# kill-l 1] SIGHUP       2) SIGINT       3) sigquit      4) Sigill 5) SIGTRAP      6) SIGABRT      7) Sigbus       

SIGFPE 9) SIGKILL) SIGUSR1) SIGSEGV SIGUSR213) sigpipe) sigalrm) SIGTERM     17) SIGCHLD18) (Sigcont) (SIGSTOP) SIGTSTP) SIGTTIN22) Sigttou) Sigurg     25 ) (SIGXFSZ26) (SIGVTALRM) sigprof) sigwinch SIGIO30) SIGPWR sigsys) sigrtmin<      c17/>35) sigrtmin+136) sigrtmin+2  Notoginseng) sigrtmin+3 (sigrtmin+4) sigrtmin+540  ) sigrtmin+6  41) sigrtmin+7) (  sigrtmin+8) sigrtmin+944) (sigrtmin+10) sigrtmin+11) sigrtmin+12)  SIGRTMIN+14) (sigrtmin+15) SIGRTMAX-14) SIGRTMAX-1352) SIGRTMAX-12-SIGRTMAX-11) SIGRTMAX-10 6) SIGRTMAX-8 (  SIGRTMAX-7)  SIGRTMAX-6)  SIGRTMAX-560) SIGRTMAX-4  62) SIGRTMAX-2  , SIGRTMAX-164) Sigrtmax

Online search, in this document found signal 0 explanation, very good:

http://www.linuxjournal.com/content/monitoring-processes-kill-0

"Signal 0″is kind of like a moral equivalent of" ping ".

Using "kill-0 NNN" in a shell script is a good a-to-tell if-PID "NNN" is alive or not:

Signal 0 is just used to check process are exists or not.

In the other signal volume description, Original: http://hi.baidu.com/syqust/blog/item/cd8f6c633b8a617c0d33fa35.html

Signal essence signal is a simulation of interrupt mechanism at software level, in principle, a process receives a signal and the processor receives an interrupt request can be said to be the same. The signal is asynchronous, and a process does not have to wait for the signal to arrive by any action, in fact, the process does not know exactly when the signal arrives.

The signal is the only asynchronous communication mechanism in the interprocess communication mechanism, which can be regarded as asynchronous notification and what happens in the process of notifying the receiving signal. After POSIX real-time expansion, the signaling mechanism is more powerful and can deliver additional information in addition to the basic notification function.

Using Kill-l, a list of supported signals from Linux is displayed. In the list, the signals numbered 1 ~ 31 are signals that are 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.

The following is a discussion of a signal with a number less than sigrtmin (the value of the corresponding signal in the following sequence is 1–31).

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

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 leave it to the user

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.

Signal 11 means that there may be illegal memory access under certain conditions in the program.

SIGUSR2 left for users 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, 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.

SIGTSTP stops the process from running, but the signal can be processed and ignored. This signal is emitted when the user types 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 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 signals that the process will stop by default are: Sigstop,sigtstp,sigttin,sigttou The default process ignores signals such as: Sigchld,sigpwr,sigurg,sigwinch

Additionally, Sigio is exited in SVR4, which is ignored in 4.3BSD; Sigcont is continued when the process hangs, otherwise it is ignored and cannot be blocked

When terminating the program, you cannot use Sigkill in a forced situation, because Sigkill does not process the sub-process, but handles itself

Linux supports POSIX standard signals and real-time signals. Below is a brief summary of the Linux signal, with detailed details to see Man 7 signal.

The default action has the following meanings:

term termination process

Signal Take value Default action Meaning (the cause of the signal)
SIGHUP 1 Term Terminal hangs or process death
SIGINT 2 Term Interrupt signal from the keyboard
Sigquit 3 Core Departure signal from the keyboard
Sigill 4 Core Illegal instructions
Sigabrt 6 Core Abnormal signal from abort
SIGFPE 8 Core Floating-point exceptions
SIGKILL 9 Term Kill
SIGSEGV 11 Core Segment illegal error (invalid memory reference)
Sigpipe 13 Term Pipeline corruption: Write data to a pipeline that does not have a read process
Sigalrm 14 Term Timer-to-time signal from alarm
SIGTERM 15 Term Terminate
SIGUSR1 30,10,16 Term User-defined Signal 1
SIGUSR2 31,12,17 Term User-defined Signal 2
SIGCHLD 20,17,18 Ign Child process stopped or terminated
Sigcont 19,18,25 Cont If stopped, continue execution
SIGSTOP 17,19,23 Stop Stop signal not from the terminal
Sigtstp 18,20,24 Stop Stop signal from the terminal
Sigttin 21,21,26 Stop Background process Read Terminal
Sigttou 22,22,27 Stop Background Process Write Terminal
Sigbus 10,7,10 Core Bus Error (Memory access error)
Sigpoll Term Pollable event Occurrence (Sys V), synonymous with Sigio
Sigprof 27,27,29 Term Statistical distribution chart with timers to the time
Sigsys ,-, 12 Core Illegal system call (SVR4)
SIGTRAP 5 Core Trace/Breakpoint Self-trapping
Sigurg 16,23,21 Ign Socket emergency signal (4.2BSD)
Sigvtalrm 26,26,28 Term Virtual timer to time (4.2BSD)
Sigxcpu 24,24,30 Core CPU Time Exceeded (4.2BSD)
Sigxfsz 25,25,31 Core File length limit exceeded (4.2BSD)
Sigiot 6 Core IoT self-trapping, synonymous with SIGABRT
Sigemt 7,-, 7 Term
Sigstkflt -,16,- Term Coprocessor stack error (not used)
SIGIO 23,29,22 Term I/O can be performed on a descriptor
Sigcld -,-, 18 Ign Synonymous with SIGCHLD
Sigpwr 29,30,19 Term Power failure (System V)
Siginfo ,-,- Synonymous with SIGPWR
Siglost -,-,- Term File Lock missing
Sigwinch 28,28,20 Ign Window size Change (4.3BSD, Sun)
Sigunused -,31,- Term Signal not used (would be sigsys)

Description

Some of the values of the signals are hardware-related (General Alpha and SPARC architectures with the first value, i386, PPC, and SH schemas with intermediate values, the MIPS schema with a third value, which indicates that the value of the corresponding schema is unknown).

The blue is the posix.1-1990 standard signal.

Sigkill and Sigstop signals cannot be hooked, blocked, or ignored.

Cyan is the signal defined by SUSV2 and posix.1-2001.

Prior to the Linux 2.2 (including) kernel, the default action for Sigsys, SIGXCPU, Sigxfsz, and Sigbus (except for SPARC and MIPS architectures) was to terminate the process, but without core dump. Linux 2.4 follows the posix.1-2001 requirements, and the default action for these signals is changed to: terminate the process and do core dump at the same time.

Orange is the other common signal.

The Signal 29 is SIGINFO/SIGPWR on Alpha and siglost on SPARC.

SIGEMT is not described in posix.1-2001, but is still visible in most unices, the typical default action is to terminate the process and do the core dump.

SIGPWR is not described in posix.1-2001, the typical default action in some unices that use it is to ignore.

Sigio is not described in posix.1-2001, the typical default action in some unices that use it is to ignore.

Processes can change the default processing of signals by using sigaction and signal system calls (using the signal is poor portability). The process can choose one of the following 3 signal processing methods:

1, perform the default operation;

2, ignoring the signal;

3. Captures the signal, but invokes the custom handler function through the signal handle.

The signal may be blocked. Each thread in the process has a separate signal mask to indicate that the signal for this thread is blocked. The thread uses the Pthread_sigmask to set its signal mask. Single-threaded programs can use Sigprocmask to manipulate signal masks. In a multithreaded program, the default behavior for all threads to handle a specified signal is the same.

Add:

The sig_dfl,sig_ign represents a function pointer with no return value, and the pointer values are 0 and 1, which are logically the function address values that are not possible in the actual program.

SIG_DFL: Default Signal handler sig_ign: Ignore signal handler

Original address: http://www.dbafree.net/?p=870

Linux semaphore signal 0< turn >

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.