📄 signal.3
字号:
.\" SCCSID: @(#)signal.3 2.1 3/10/87.TH signal 3 VAX.SH Namesignal \- simplified software signal facilities.SH Syntax.nf#include <signal.h>.PP(*signal(\fIsig, func\fR))()void (*\fIfunc\fR)();.fi.SH Description.NXR "signal subroutine (standard C)".NXR "signal" "changing action".NXA "sigvec system call" "signal subroutine (standard C)"The.PN signalsubroutineis a simplified interface to the more general sigvec(2)facility..PPA signalis generated by some abnormal event,initiated by a user at a terminal (quit, interrupt, stop),by a program error (bus error, etc.),by request of another program (kill),or when a process is stopped because it wishes to accessits control terminal while in the background. For furtherinformation, see .MS tty 4 ..PPsignals are optionally generatedwhen a process resumes after being stopped,when the status of child process changes,or when input is ready at the control terminal.Most signals cause termination of the receiving process if no actionis taken; some signals instead cause the process receiving themto be stopped, or are simply discarded if the process has notrequested otherwise.Except for the SIGKILL and SIGSTOPsignals, the.PN signalcall allows signals either to be ignoredor to cause an interrupt to a specified location.The following is a list of all signals withnames as in the include file < signal.h >:.PP.NXR "signal subroutine (standard C)" "signal list".nf.ta \w'SIGVTALRM 'u +\w'15* 'uSIGHUP 1 HangupSIGINT 2 InterruptSIGQUIT 3* QuitSIGILL 4* Illegal instructionSIGTRAP 5* Trace trapSIGIOT 6* IOT instructionSIGEMT 7* EMT instructionSIGFPE 8* Floating point exceptionSIGKILL 9 Kill (cannot be caught or ignored)SIGBUS 10* Bus errorSIGSEGV 11* Segmentation violationSIGSYS 12* Bad argument to system callSIGPIPE 13 write on a pipe with no one to read itSIGALRM 14 Alarm clockSIGTERM 15 Software termination signalSIGURG 16\(bu Urgent condition present on socketSIGSTOP 17+ Stop (cannot be caught or ignored)SIGTSTP 18+ Stop signal generated from keyboardSIGCONT 19\(bu Continue after stopSIGCHLD 20\(bu Child status has changedSIGTTIN 21+ Background read attempted from control terminalSIGTTOU 22+ Background write attempted to control terminalSIGIO 23\(bu I/O is possible on a descriptor (see fcntl(2))SIGXCPU 24 Cpu time limit exceeded (see setrlimit(2))SIGXFSZ 25 File size limit exceeded (see setrlimit(2))SIGVTALRM 26 Virtual time alarm (see setitimer(2))SIGPROF 27 Profiling timer alarm (see setitimer(2))SIGWINCH 28\(bu Window size changeSIGLOST 29 lock not reclaimed after server recoverySIGUSR1 30 User defined signalSIGUSR2 31 User defined signalSIGCLD System V name for SIGCHLDSIGABRT X/OPEN name for SIGIOT.fi.PPThe starred signals in the list above cause a core imageif not caught or ignored..PPIf.I funcis SIG_DFL, the default actionfor signal.I sigis reinstated; this default is termination(with a core image for starred signals)except for signals marked with \(bu or +.Signals marked with \(bu are discarded if the actionis SIG_DFL; signals markedwith + cause the process to stop.If.I funcis SIG_IGN the signal is subsequently ignoredand pending instances of the signal are discarded.Otherwise, when the signal occursfurther occurrences of the signal areautomatically blocked and.I funcis called..PPA return from the function unblocksthe handled signal andcontinues the process at the point it was interrupted.Unlike previous signal facilities, the handler \fIfunc\fPremains installed after a signal has been delivered..PPIf a caught signal occursduring certain system calls, causingthe call to terminate prematurely, the callis automatically restarted.In particular this can occurduring a.I reador .MS write 2on a slow device (such as a terminal; but not a file)and during a .MS wait 2 ..PPThe value of.PN signalis the previous (or initial)value of.I funcfor the particular signal..PPAfter a .MS fork 2or .MS vfork 2the child inheritsall signals.The.MS execve 2system callresets all caught signals to the default action;ignored signals remain ignored..SH VAX-11 NotesThe handler routine can be declared:.EXhandler(sig, code, scp).EEHere.I sigis the signal number, into which the hardware faults and traps aremapped as defined below. Code is a parameter which is either a constantas given below or, for compatibility mode faults, the code provided bythe hardware. The .I scpis a pointer to the.I "struct sigcontext"used by the system to restore the process context from beforethe signal.Compatibility mode faults are distinguished from theother SIGILL traps by having PSL_CM set in the psl..PPThe following defines the mapping of hardware traps to signalsand codes. All of these symbols are defined in < signal.h >:.PP.NXR "signal subroutine (standard C)" "mapping hardware traps to signals".ta \w' Floating/decimal divide by zero 'u +\w'15* 'u +8n.nf Hardware condition Signal CodeArithmetic traps: Integer overflow SIGFPE FPE_INTOVF_TRAP Integer division by zero SIGFPE FPE_INTDIV_TRAP Floating overflow trap SIGFPE FPE_FLTOVF_TRAP Floating/decimal division by zero SIGFPE FPE_FLTDIV_TRAP Floating underflow trap SIGFPE FPE_FLTUND_TRAP Decimal overflow trap SIGFPE FPE_DECOVF_TRAP Subscript-range SIGFPE FPE_SUBRNG_TRAP Floating overflow fault SIGFPE FPE_FLTOVF_FAULT Floating divide by zero fault SIGFPE FPE_FLTDIV_FAULT Floating underflow fault SIGFPE FPE_FLTUND_FAULTLength access control SIGSEGV fault virtual addrProtection violation SIGBUS fault virtual addrReserved instruction SIGILL ILL_PRIVIN_FAULTCustomer-reserved instr. SIGEMTReserved operand SIGILL ILL_RESOP_FAULTReserved addressing SIGILL ILL_RESAD_FAULTTrace pending SIGTRAPBpt instruction SIGTRAPCompatibility-mode SIGILL hrdwr suppl'd codeChme SIGSEGVChms SIGSEGVChmu SIGSEGV.fi.SH Return Values.NXR "signal subroutine (standard C)" "return value"The previous action is returned on a successful call.Otherwise, \-1 is returned and .I errnois set to indicate the error..SH DiagnosticsThe.PN signalsubroutinewill fail and no action will take place if one of thefollowing occur:.TP 15[EINVAL]The.I sigis not a valid signal number..TP 15[EINVAL]An attempt is made to ignore or supply a handler for SIGKILLor SIGSTOP..SH EnvironmentWhen your program is compiled using the System V environment the handlerfunction does NOT remain installed after the signal has been delivered..PPAlso, when a signal which is to be caught occurs during aread(), write(), or ioctl() to a slow device (likea terminal, but not a file); or during a pause(); orwait() that does not return immediately, the signal handler function is executed,and then the interrupted system call mayreturn a \-1 to the calling process with errno setto EINTR..SH See Alsokill(1), kill(2), ptrace(2), sigblock(2), sigpause(2),sigsetmask(2), sigstack(2), sigvec(2), setjmp(3), tty(4)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -