分类: LINUX
2009-11-29 13:28:20
Let the default action apply. Every signal has a default action, shown in . Note that the default action for most signals is to terminate the process.
Name |
Description |
ISO C |
SUS |
FreeBSD 5.2.1 |
Linux 2.4.22 |
Mac OS X 10.3 |
Solaris 9 |
Default action |
---|---|---|---|---|---|---|---|---|
SIGABRT |
abnormal termination (abort) |
• |
• |
• |
• |
• |
• |
terminate+core |
SIGALRM |
timer expired (alarm) |
• |
• |
• |
• |
• |
terminate | |
SIGBUS |
hardware fault |
• |
• |
• |
• |
• |
terminate+core | |
SIGCANCEL |
threads library internal use |
• |
ignore | |||||
SIGCHLD |
change in status of child |
• |
• |
• |
• |
• |
ignore | |
SIGCONT |
continue stopped process |
• |
• |
• |
• |
• |
continue/ignore | |
SIGEMT |
hardware fault |
• |
• |
• |
• |
terminate+core | ||
SIGFPE |
arithmetic exception |
• |
• |
• |
• |
• |
• |
terminate+core |
SIGFREEZE |
checkpoint freeze |
• |
ignore | |||||
SIGHUP |
hangup |
• |
• |
• |
• |
• |
terminate | |
SIGILL |
illegal instruction |
• |
• |
• |
• |
• |
• |
terminate+core |
SIGINFO |
status request from keyboard |
• |
• |
ignore | ||||
SIGINT |
terminal interrupt character |
• |
• |
• |
• |
• |
• |
terminate |
SIGIO |
asynchronous I/O |
• |
• |
• |
• |
terminate/ignore | ||
SIGIOT |
hardware fault |
• |
• |
• |
• |
terminate+core | ||
SIGKILL |
termination |
• |
• |
• |
• |
• |
terminate | |
SIGLWP |
threads library internal use |
• |
ignore | |||||
SIGPIPE |
write to pipe with no readers |
• |
• |
• |
• |
• |
terminate | |
SIGPOLL |
pollable event (poll) |
XSI |
• |
• |
terminate | |||
SIGPROF |
profiling time alarm (setitimer) |
XSI |
• |
• |
• |
• |
terminate | |
SIGPWR |
power fail/restart |
• |
• |
terminate/ignore | ||||
SIGQUIT |
terminal quit character |
• |
• |
• |
• |
• |
terminate+core | |
SIGSEGV |
invalid memory reference |
• |
• |
• |
• |
• |
• |
terminate+core |
SIGSTKFLT |
coprocessor stack fault |
• |
terminate | |||||
SIGSTOP |
stop |
• |
• |
• |
• |
• |
stop process | |
SIGSYS |
invalid system call |
XSI |
• |
• |
• |
• |
terminate+core | |
SIGTERM |
termination |
• |
• |
• |
• |
• |
• |
terminate |
SIGTHAW |
checkpoint thaw |
• |
ignore | |||||
SIGTRAP |
hardware fault |
XSI |
• |
• |
• |
• |
terminate+core | |
SIGTSTP |
terminal stop character |
• |
• |
• |
• |
• |
stop process | |
SIGTTIN |
background read from control tty |
• |
• |
• |
• |
• |
stop process | |
SIGTTOU |
background write to control tty |
• |
• |
• |
• |
• |
stop process | |
SIGURG |
urgent condition (sockets) |
• |
• |
• |
• |
• |
ignore | |
SIGUSR1 |
user-defined signal |
• |
• |
• |
• |
• |
terminate | |
SIGUSR2 |
user-defined signal |
• |
• |
• |
• |
• |
terminate | |
SIGVTALRM |
virtual time alarm (setitimer) |
XSI |
• |
• |
• |
• |
terminate | |
SIGWAITING |
threads library internal use |
• |
ignore | |||||
SIGWINCH |
terminal window size change |
• |
• |
• |
• |
ignore | ||
SIGXCPU |
CPU limit exceeded (setrlimit) |
XSI |
• |
• |
• |
• |
terminate+core/ignore | |
SIGXFSZ |
file size limit exceeded (setrlimit) |
XSI |
• |
• |
• |
• |
terminate+core/ignore | |
SIGXRES |
resource control exceeded |
• |
ignore |
lists the names of all the signals, an indication of which systems support the signal, and the default action for the signal. The SUS column contains • if the signal is defined as part of the base POSIX.1 specification and XSI if it is defined as an XSI extension to the base.
When the default action is labeled "terminate+core," it means that a memory image of the process is left in the file named core of the current working directory of the process. (Because the file is named core, it shows how long this feature has been part of the UNIX System.) This file can be used with most UNIX System debuggers to examine the state of the process at the time it terminated.
2.上表中的信号说明:
We now describe each of these signals in more detail.
SIGABRT |
This signal is generated by calling the abort function (). The process terminates abnormally. |
SIGALRM |
This signal is generated when a timer set with the alarm function expires (see for more details). This signal is also generated when an interval timer set by the setitimer(2) function expires. |
SIGBUS |
This indicates an implementation-defined hardware fault. Implementations usually generate this signal on certain types of memory faults, as we describe in . |
SIGCANCEL |
This signal is used internally by the Solaris threads library. It is not meant for general use. |
SIGCHLD |
Whenever a process terminates or stops, the SIGCHLD signal is sent to the parent. By default, this signal is ignored, so the parent must catch this signal if it wants to be notified whenever a child's status changes. The normal action in the signal-catching function is to call one of the wait functions to fetch the child's process ID and termination status. Earlier releases of System V had a similar signal named SIGCLD (without the H). The semantics of this signal were different from those of other signals, and as far back as SVR2, the manual page strongly discouraged its use in new programs. (Strangely enough, this warning disappeared in the SVR3 and SVR4 versions of the manual page.) Applications should use the standard SIGCHLD signal, but be aware that many systems define SIGCLD to be the same as SIGCHLD for backward compatibility. If you maintain software that uses SIGCLD, you need to check your system's manual page to see what semantics it follows. We discuss these two signals in . |
SIGCONT |
This job-control signal is sent to a stopped process when it is continued. The default action is to continue a stopped process, but to ignore the signal if the process wasn't stopped. A full-screen editor, for example, might catch this signal and use the signal handler to make a note to redraw the terminal screen. See for additional details. |
SIGEMT |
This indicates an implementation-defined hardware fault.
|
SIGFPE |
This signals an arithmetic exception, such as divide by 0, floating-point overflow, and so on. |
SIGFREEZE |
This signal is defined only by Solaris. It is used to notify processes that need to take special action before freezing the system state, such as might happen when a system goes into hibernation or suspended mode. |
SIGHUP |
This signal is sent to the controlling process (session leader) associated with a controlling terminal if a disconnect is detected by the terminal interface. Referring to , we see that the signal is sent to the process pointed to by the s_leader field in the session structure. This signal is generated for this condition only if the terminal's CLOCAL flag is not set. (The CLOCAL flag for a terminal is set if the attached terminal is local. The flag tells the terminal driver to ignore all modem status lines. We describe how to set this flag in .) Note that the session leader that receives this signal may be in the background; see for an example. This differs from the normal terminal-generated signals (interrupt, quit, and suspend), which are always delivered to the foreground process group. This signal is also generated if the session leader terminates. In this case, the signal is sent to each process in the foreground process group. This signal is commonly used to notify daemon processes () to reread their configuration files. The reason SIGHUP is chosen for this is that a daemon should not have a controlling terminal and would normally never receive this signal. |
SIGILL |
This signal indicates that the process has executed an illegal hardware instruction.
|
SIGINFO |
This BSD signal is generated by the terminal driver when we type the status key (often Control-T). This signal is sent to all processes in the foreground process group (refer to ). This signal normally causes status information on processes in the foreground process group to be displayed on the terminal.
|
SIGINT |
This signal is generated by the terminal driver when we type the interrupt key (often DELETE or Control-C). This signal is sent to all processes in the foreground process group (refer to ). This signal is often used to terminate a runaway program, especially when it's generating a lot of unwanted output on the screen. |
SIGIO |
This signal indicates an asynchronous I/O event. We discuss it in .
|
SIGIOT |
This indicates an implementation-defined hardware fault.
|
SIGKILL |
This signal is one of the two that can't be caught or ignored. It provides the system administrator with a sure way to kill any process. |
SIGLWP |
This signal is used internally by the Solaris threads library, and is not available for general use. |
SIGPIPE |
If we write to a pipeline but the reader has terminated, SIGPIPE is generated. We describe pipes in . This signal is also generated when a process writes to a socket of type SOCK_STREAM that is no longer connected. We describe sockets in . |
SIGPOLL |
This signal can be generated when a specific event occurs on a pollable device. We describe this signal with the poll function in . SIGPOLL originated with SVR3, and loosely corresponds to the BSD SIGIO and SIGURG signals.
|
SIGPROF |
This signal is generated when a profiling interval timer set by the setitimer(2) function expires. |
SIGPWR |
This signal is system dependent. Its main use is on a system that has an uninterruptible power supply (UPS). If power fails, the UPS takes over and the software can usually be notified. Nothing needs to be done at this point, as the system continues running on battery power. But if the battery gets low (if the power is off for an extended period), the software is usually notified again; at this point, it behooves the system to shut everything down within about 1530 seconds. This is when SIGPWR should be sent. Most systems have the process that is notified of the low-battery condition send the SIGPWR signal to the init process, and init handles the shutdown.
|
SIGQUIT |
This signal is generated by the terminal driver when we type the terminal quit key (often Control-backslash). This signal is sent to all processes in the foreground process group (refer to ). This signal not only terminates the foreground process group (as does SIGINT), but also generates a core file. |
SIGSEGV |
This signal indicates that the process has made an invalid memory reference.
|
SIGSTKFLT |
This signal is defined only by Linux. This signal showed up in the earliest versions of Linux, intended to be used for stack faults taken by the math coprocessor. This signal is not generated by the kernel, but remains for backward compatibility. |
SIGSTOP |
This job-control signal stops a process. It is like the interactive stop signal (SIGTSTP), but SIGSTOP cannot be caught or ignored. |
SIGSYS |
This signals an invalid system call. Somehow, the process executed a machine instruction that the kernel thought was a system call, but the parameter with the instruction that indicates the type of system call was invalid. This might happen if you build a program that uses a new system call and you then try to run the same binary on an older version of the operating system where the system call doesn't exist. |
SIGTERM |
This is the termination signal sent by the kill(1) command by default. |
SIGTHAW |
This signal is defined only by Solaris and is used to notify processes that need to take special action when the system resumes operation after being suspended. |
SIGTRAP |
This indicates an implementation-defined hardware fault.
|
SIGTSTP |
This interactive stop signal is generated by the terminal driver when we type the terminal suspend key (often Control-Z). This signal is sent to all processes in the foreground process group (refer to ).
|
SIGTTIN |
This signal is generated by the terminal driver when a process in a background process group tries to read from its controlling terminal. (Refer to the discussion of this topic in .) As special cases, if either (a) the reading process is ignoring or blocking this signal or (b) the process group of the reading process is orphaned, then the signal is not generated; instead, the read operation returns an error with errno set to EIO. |
SIGTTOU |
This signal is generated by the terminal driver when a process in a background process group tries to write to its controlling terminal. (Refer to the discussion of this topic in .) Unlike the SIGTTIN signal just described, a process has a choice of allowing background writes to the controlling terminal. We describe how to change this option in . If background writes are not allowed, then like the SIGTTIN signal, there are two special cases: if either (a) the writing process is ignoring or blocking this signal or (b) the process group of the writing process is orphaned, then the signal is not generated; instead, the write operation returns an error with errno set to EIO. Regardless of whether background writes are allowed, certain terminal operations (other than writing) can also generate the SIGTTOU signal: tcsetattr, tcsendbreak, tcdrain, tcflush, tcflow, and tcsetpgrp. We describe these terminal operations in . |
SIGURG |
This signal notifies the process that an urgent condition has occurred. This signal is optionally generated when out-of-band data is received on a network connection. |
SIGUSR1 |
This is a user-defined signal, for use in application programs. |
SIGUSR2 |
This is another user-defined signal, similar to SIGUSR1, for use in application programs. |
SIGVTALRM |
This signal is generated when a virtual interval timer set by the setitimer(2) function expires. |
SIGWAITING |
This signal is used internally by the Solaris threads library, and is not available for general use. |
SIGWINCH |
The kernel maintains the size of the window associated with each terminal and pseudo terminal. A process can get and set the window size with the ioctl function, which we describe in . If a process changes the window size from its previous value using the ioctl set-window-size command, the kernel generates the SIGWINCH signal for the foreground process group. |
SIGXCPU |
The Single UNIX Specification supports the concept of resource limits as an XSI extension; refer to . If the process exceeds its soft CPU time limit, the SIGXCPU signal is generated.
|
SIGXFSZ |
This signal is generated if the process exceeds its soft file size limit; refer to .
|
SIGXRES |
This signal is defined only by Solaris. This signal is optionally used to notify processes that have exceeded a preconfigured resource value. The Solaris resource control mechanism is a general facility for controlling the use of shared resources among independent application sets. |
SIGCHLD |
Child process has stopped or terminated. |
SIGCONT |
Continue process, if stopped. |
SIGSTOP |
Stop signal (can't be caught or ignored). |
SIGTSTP |
Interactive stop signal. |
SIGTTIN |
Read from controlling terminal by member of a background process group. |
SIGTTOU |
Write to controlling terminal by member of a background process group. |
There are some interactions between the job-control signals. When any of the four stop signals (SIGTSTP, SIGSTOP, SIGTTIN, or SIGTTOU) is generated for a process, any pending SIGCONT signal for that process is discarded. Similarly, when the SIGCONT signal is generated for a process, any pending stop signals for that same process are discarded.
3》SIGCONT
Note that the default action for SIGCONT is to continue the process, if it is stopped; otherwise, the signal is ignored. Normally, we don't have to do anything with this signal. When SIGCONT is generated for a process that is stopped, the process is continued, even if the signal is blocked or ignored.