📄 sigaction.2
字号:
.\" This -*- nroff -*- file has been generated from.\" DocBook SGML with docbook-to-man on Debian GNU/Linux....\"...\" transcript compatibility for postscript use....\"...\" synopsis: .P! <file.ps>...\".de P!\\&..fl \" force out current output buffer\\!%PB\\!/showpage{}def...\" the following is from Ken Flowers -- it prevents dictionary overflows\\!/tempdict 200 dict def tempdict begin.fl \" prolog.sy cat \\$1\" bring in postscript file...\" the following line matches the tempdict above\\!end % tempdict %\\!PE\\!..sp \\$2u \" move below the image...de pF.ie \\*(f1 .ds f1 \\n(.f.el .ie \\*(f2 .ds f2 \\n(.f.el .ie \\*(f3 .ds f3 \\n(.f.el .ie \\*(f4 .ds f4 \\n(.f.el .tm ? font overflow.ft \\$1...de fP.ie !\\*(f4 \{\. ft \\*(f4. ds f4\"' br \}.el .ie !\\*(f3 \{\. ft \\*(f3. ds f3\"' br \}.el .ie !\\*(f2 \{\. ft \\*(f2. ds f2\"' br \}.el .ie !\\*(f1 \{\. ft \\*(f1. ds f1\"' br \}.el .tm ? font underflow...ds f1\".ds f2\".ds f3\".ds f4\"'\" t .ta 8n 16n 24n 32n 40n 48n 56n 64n 72n .TH "sigaction" "2" .SH "NAME" sigaction \(em RTLinux POSIX signal handling functions .SH "SYNOPSIS" .PP .nf .ta 8n 16n 24n 32n 40n 48n 56n 64n 72n #include <posix/signal.h> int \fBsigaction\fP(int \fBsignum\fR, const struct sigaction *\fBact\fR, struct sigaction *\fBoldact\fR); int \fBsigprocmask\fP(int \fBhow\fR, const sigset_t *\fBset\fR, sigset_t *\fBoldset\fR); .fi .SH "DESCRIPTION" .PP Signals interactions with pthreads is one of the less well defined and most contentious parts of POSIX. Many problems come from the interaction between process signals and thread signals. RTLinux V3.0 uses the concept of process signals to provide an interface to hard interrupt handlers. The signals RTL_SIGIRQMIN to RTL_SIGIRQMIN + NR_IRQS refer to global hardware interrupts, and installing signal handlers is the same as installing interrupt handlers. .PP RTLinux provides the POSIX \fBsigaction\fP function to install handlers for hardware interrupts and also to provide POSIX signaling (this is incomplete in V3.0). .PP \fBsignum\fR specifies the signal and can be any valid signal except \fBSIGKILL\fP and \fBSIGSTOP\fP. .PP If \fBact\fR is non-null, the new action for signal \fBsignum\fR is installed from \fBact\fR. If \fBoldact\fR is non-null, the previous action is saved in \fBoldact\fR. .PP The \fBsigaction\fP structure is defined as .PP .nf .ta 8n 16n 24n 32n 40n 48n 56n 64n 72n \f(CW struct sigaction{ void (*sa_handler)(int); sigset_t sa_mask; int sa_flags; void (*sa_restorer)(void); unsigned int sa_focus; }\fR .fi .PP The \fBsa_focus\fR field is an RTLinux-specific extension that is a bit map defining which processors on an SMP system can accept these interrupts. This is machine-specific and may only be used for hardware interrupts using the RTL_SIGIRQMIN+n, to catch hardware interrupt n. .PP \fBsa_handler\fR specifies the action to be associated with signum and may be \fBSIG_DFL\fP for the default action, \fBSIG_IGN\fP to ignore this signal, or a pointer to a signal handling function. .PP \fBsa_mask\fR gives a mask of signals which should be blocked during execution of the signal handler. In addition, the signal which triggered the handler will be blocked, unless the \fBSA_NODEFER\fP or \fBSA_NOMASK\fP flags are used. In V3 and prior RTLinux these flags have no effect. Furthermore, when a signal handler for a hard interrupt is entered all interrupts are blocked by default. .PP \fBsa_flags\fR specifies a set of flags which modify the behaviour of the signal handling process. In RTLinux V3.0 and earlier these flags are ignored. .PP The \fBsa_focus\fR element is used to direct a hardware interrupt to a particular set of processors in an SMP system. This element has no effiect on soft-interrupts, on processor-specific interrupts (e.g. local timers and IPIs), on uni-processor systems, or where the interrupt control logic does not support interrupt focus. .PP The \fBsigprocmask\fP call is used to change the list of currently blocked signals in a single threaded process. POSIX states that the sigprocmask call has undefined operation in a multi-threaded process. In RTLinux, if the pthreads-based scheduling module (\fBrtl_sched\fP) is loaded or otherwise activated, the RT process is multithreaded and sigprocmask behavior undefined, unless the ``\fIhow\fP'' variable is set to \fBSIG_DISABLE\fP or \fBSIG_ENABLE\fP. These two flags are RTLinux extensions. The behaviour of the call is dependent on the value of how, as follows. .PP .IP "\fBSIG_BLOCK\fP" 10 The set of blocked signals is the union of the current set and the set argument. .IP "\fBSIG_UNBLOCK\fP" 10 The signals in set are removed from the current set of blocked signals. It is legal to attempt to unblock a signal which is not blocked. .IP "\fBSIG_SETMASK\fP" 10 The set of blocked signals is set to the argument set. .IP "\fBSIG_DISABLE\fP" 10 Turns on local processor interrupts. .IP "\fBSIG_ENABLE\fP" 10 Turns on local processor interrupts. .PP Note that in RTLinux, as in POSIX, not all signals can be masked or blocked. .PP If \fBoldset\fR is non-null, the previous value of the signal mask is stored in \fBoldset\fR. .SH "RETURN VALUES" .PP \fBsigaction\fP, \fBsigprocmask\fP, \fBsigpending\fP and \fBsigsuspend\fP return 0 on success and -1 on error. .SH "ERRORS" .IP "EINVAL" 10 An invalid signal was specified. This will also be generated if an attempt is made to change the action for \fBSIGKILL\fP or \fBSIGSTOP\fP, which cannot be caught. .IP "EFAULT" 10 \fBact\fR,\fBoldact\fR, \fBset\fR or \fBoldset\fR point to memory which is not a valid part of the process address space. .IP "EINTR" 10 System call was interrupted. This cannot happen in RTLinux V3.0 or prior. .SH "NOTES" .PP It is not possible to block \fBSIGKILL\fP or \fBSIGSTOP\fP with the \fBsigprocmask\fP call. Attempts to do so will be silently ignored. RTLinux also adds an additional set of unmaskable and uncatchable signals. .PP According to POSIX, the behaviour of a process is undefined after it ignores a \fBSIGFP\fPE, \fBSIGILL\fP, or \fBSIGSEGV\fP signal that was not generated by the \fBkill()\fP or the \fBraise()\fP functions. Integer division by zero has undefined result. On some architectures it will generate a \fBSIGFPE\fP signal. (Also, dividing the most negative integer by -1 may generate \fBSIGFPE\fP.) Ignoring this signal might lead to an endless loop. .PP \fBSIGCHLD\fP cannot happen in V3.0 RTLinux or prior, since there is no way to create child processes. .PP The POSIX spec only defines SA_NOCLDSTOP. Use of other \fBsa_flags\fR is non-portable. .PP \fBsigaction\fP can be called with a null second argument to query the current signal handler. It can also be used to check whether a given signal is valid for the current machine, by calling it with null second and third arguments. .SH "SEE ALSO" \fIUNIX spec sigaction (link to URL ../susv2/xsh/sigaction.html) \fR, \fIUNIX spec kill(2) (link to URL ../susv2/xsh/kill.html) \fR .PP \(co2001 FSMLabs Inc. .PP All rights reserved. ...\" created by instant / docbook-to-man, Thu 26 Jul 2001, 11:20
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -