- 论坛徽章:
- 0
|
请教trap用法,求signal信号列表
The sig argument can be assigned any one of the following values except
SIGKILL and SIGSTOP:
---------------------------------------------------------------------------------------
Signal Value Description XPG 3 POSIX ANSI
---------------------------------------------------------------------------------------
SIGHUP 01 hangup o o
SIGINT 02 interrupt o o o
SIGQUIT 03[1] quit o o
SIGILL 04[1] illegal instruction (not reset when caught) o o o
SIGTRAP 05[1] trace trap (not reset when caught)
SIGIOT 06[1] IOT instruction
SIGABRT 06[1] used by abort, replaces SIGIOT o o o
SIGEMT 07[1] EMT instruction
SIGFPE 08[1] floating point exception o o o
SIGKILL 09 kill (cannot be caught or ignored) o o
SIGBUS 10[1] bus error
SIGSEGV 11[1] segmentation violation o o o
SIGSYS 12[1] bad argument to system call
SIGPIPE 13 write on a pipe with no one to read it o o
SIGALRM 14 alarm clock o o
SIGTERM 15 software termination signal o o o
SIGUSR1 16 user-defined signal 1 o o
SIGUSR2 17 user-defined signal 2 o o
SIGCLD 18[3] death of a child
SIGCHLD 18[3] synonym for SIGCLD
SIGPWR 19[3] power fail
SIGWINCH 20 window change
SIGPOLL 22[4] selectable event pending
SIGSTOP 23[2] sendable stop signal not from tty o o
SIGTSTP 24[2] stop signal from tty o o
SIGCONT 25[2] continue a stopped process o o
SIGTTIN 26[2] background tty read attempt o o
SIGTTOU 27[2] background tty write attempt o o
SIGVTALRM 28 virtual timer alarm
SIGPROF 29 profile alarm
The func argument is assigned one of the following three values: SIG_DFL,
SIG_IGN, or an address of a function defined by the user. SIG_DFL, and
SIG_IGN, are defined in the header file <signal.h>;. Each is a macro that
expands to a constant expression of type pointer to function returning
void, and having a unique value that does not match a declarable function.
The actions prescribed by the values of the func argument are as follows:
SIG_DFL -- execute default signal action
Upon receipt of the signal specified by sig, the receiving process
will take the default action. The default action usually results in
the termination of the process with all of the consequences
outlined in exit(S). Those signals with a [1] or a [2] are
exceptions to this rule. Their default behavior is described in the
corresponding Note section.
SIG_IGN -- ignore signal
Upon receipt of the signal specified by sig, the signal is ignored.
____________________________________________________________________________
NOTE: The SIGKILL and SIGSTOP signals cannot be ignored.
____________________________________________________________________________
signal-catching function -- execute user-defined action
Upon receipt of the signal sig, the receiving process executes the
signal-catching function pointed to by func. The signal number
sig is passed as the only argument to the signal-catching function.
Additional arguments are passed to the signal-catching function for
hardware-generated signals. Before entering the signal-catching
function, the value of func for the caught signal is set to SIG_DFL
unless the signal is SIGILL, SIGTRAP, or SIGPWR.
Upon return from the signal-catching function, the receiving process
resumes execution at the point it was interrupted.
The signal catching function is not executed during certain slow
processes even though a signal has been caught. Slow processes are
considered to be read(S), write(S), open(S), or ioctl(S) system
calls on a slow device (like a terminal; but not a file), a pause
(S) routine, or during a wait(S) routine that does not return
immediately due to the existence of a previously stopped or zombie
process. Then the interrupted system call may return a -1 to the
calling process with errno set to EINTR.
The signal routine does not catch an invalid function argument,
func, and results are undefined when an attempt is made to execute
the function at the bad address.
____________________________________________________________________________
NOTE: The SIGKILL and SIGSTOP signals cannot be caught.
____________________________________________________________________________
A call to signal cancels a pending signal sig except for a pending SIGKILL
or SIGSTOP signal. |
|