⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sigactio.2

📁 Unix操作系统minix 2.0源码
💻 2
字号:
.TH SIGACTION 2.SH NAMEsigaction, signal \- manage signal state and handlers.SH SYNOPSIS.ft B#include <signal.h>.in +5.ti -5int sigaction(int \fIsig\fP, const struct sigaction *\fIact\fP, struct sigaction *\fIoact\fP).in -5.brvoid (*signal(int \fIsig\fP, void (*\fIhandler\fP)(int)))(int);.ft P.SH DESCRIPTION.de SP.if t .sp 0.4.if n .sp...B Sigaction()is used to examine, set, or modify the attributes of a signal.  The argument.I sigis the signal in question.  The.I actargument points to a structure containing the new attributes of the signal,the structure pointed to by.I oactwill receive the old attributes that were in effect before the call..PPThe.I actand.I oactarguments may be.B NULLto indicate that either no new attributes are to be set, or that the oldattributes are not of interest..PPThe structure containing the signal attributes is defined in <signal.h> andlooks like this:.PP.RS.nf.ft B.ta +4n +12nstruct sigaction {	void	(*sa_handler)(int sig);	sigset_t	sa_mask;	int	sa_flags;};.ft R.fi.RE.PPThe.B sa_handlerfield contains the address of a signal handler, a function that is calledwhen the process is signalled, or one of these special constants:.PP.TP 12.B SIG_DFLDefault signal handling is to be performed.  This usually means that theprocess is killed, but some signals may be ignored by default..TP.B SIG_IGNIgnore the signal..PPThe.B sa_maskfield indicates a set of signals that must be blocked when the signal isbeing handled.  Whether the signal.I sigitself is blocked when being handled is not controlled by this mask.  Themask is of a "signal set" type that is to be manipulated by the.BR sigset (3)functions..PPHow the signal is handled precisely is specified by bits in.BR sa_flags .If none of the flags is set then the handler is called when the signalarrives.  The signal is blocked during the call to the handler, andunblocked when the handler returns.  A system call that is interruptedreturns.B \-1with.B errnoset to.BR EINTR .The following bit flags can be set to modify this behaviour:.PP.TP 15.B SA_RESETHANDReset the signal handler to.B SIG_DFLwhen the signal is caught..TP.B SA_NODEFERDo not block the signal on entry to the handler..TP.B SA_COMPATHandle the signal in a way that is compatible with the the old.B signal()call..PPThe old.B signal()signal system call sets a signal handler for a given signal and returns theold signal handler.  No signals are blocked, the flags are.BR "SA_RESETHAND | SA_NODEFER | SA_COMPAT" .New code should not use.BR signal() .Note that.B signal()and all of the.B SA_*flags are Minix extensions..PPSignal handlers are reset to.B SIG_DFLon an.BR execve (2).Signals that are ignored stay ignored..SS SignalsMinix knows about the following signals:.PP.nf.ta +11n +7n +8nsignal	num	notes	description.SPSIGHUP	1	k	HangupSIGINT	2	k	Interrupt (usually DEL or CTRL\-C)SIGQUIT	3	kc	Quit (usually CTRL\-\e)SIGILL	4	kc	Illegal instructionSIGTRAP	5	xkc	Trace trapSIGABRT	6	kc	Abort programSIGFPE	8	k	Floating point exceptionSIGKILL	9	k	KillSIGUSR1	10	k	User defined signal #1SIGSEGV	11	kc	Segmentation faultSIGUSR2	12	k	User defined signal #2SIGPIPE	13	k	Write to a pipe with no readerSIGALRM	14	k	Alarm clockSIGTERM	15	k	Terminate (default for kill(1))SIGCHLD	17	pvi	Child process terminatedSIGCONT	18	p	Continue if stoppedSIGSTOP	19	ps	Stop signalSIGTSTP	20	ps	Interactive stop signalSIGTTIN	21	ps	Background readSIGTTOU	22	ps	Background writeSIGWINCH	23	xvi	Window size change.ft R.fi.PPThe letters in the notes column indicate:.PP.TP 5.B kThe process is killed if the signal is not caught..TP.B cThe signal causes a core dump..TP.B iThe signal is ignored if not caught..TP.B vOnly Minix-vmd implements this signal..TP.B xMinix extension, not defined by \s-2POSIX\s+2..TP.B pThese signals are not implemented, but \s-2POSIX\s+2 requires that they aredefined..TP.B sThe process should be stopped, but is killed instead..PPThe.B SIGKILLsignal cannot be caught or ignored.  The.B SIGILLand.B SIGTRAPsignals cannot be automatically reset.  The system silently enforces theserestrictions.  This may or may not be reflected by the attributes of thesesignals and the signal masks..SS Types\s-2POSIX\s+2 prescribes that <sys/types.h> has the following definition:.PP.RS.B "typedef int (*sighandler_t)(int)".RE.PPWith this type the following declarations can be made:.PP.RS.ft B.nfsighandler_t sa_handler;sighandler_t signal(int \fIsig\fP, sighandler_t \fIhandler\fP);.fi.ft R.RE.PPThis may help you to understand the earlier declarations better.  The.B sighandler_ttype is also very useful in old style C code that is compiled by a compilerfor standard C..SH "SEE ALSO".BR kill (1),.BR kill (2),.BR pause (2),.BR sigprocmask (2),.BR sigsuspend (2),.BR sigpending (2),.BR sigset (3)..SH DIAGNOSTICS.B Sigaction()returns.B 0on success or.B \-1on error..B Signal()returns the old handler on success or.B SIG_ERRon error.  The error code may be:.PP.TP 10.B EINVALBad signal number..TP.B EFAULTBad.I actor.I oactaddresses..SH AUTHORKees J. Bot (kjb@cs.vu.nl)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -