Print this page
5281 incorrect realtime signal delivery
   1 '\" te

   2 .\" Copyright (c) 2007, Sun Microsystems, Inc.  All Rights Reserved.
   3 .\" Copyright 1989 AT&T
   4 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
   5 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
   6 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
   7 .TH SIGACTION 2 "Mar 23, 2005"
   8 .SH NAME
   9 sigaction \- detailed signal management
  10 .SH SYNOPSIS
  11 .LP
  12 .nf
  13 #include <signal.h>
  14 
  15 \fBint\fR \fBsigaction\fR(\fBint\fR \fIsig\fR, \fBconst struct sigaction *restrict\fR \fIact\fR,
  16      \fBstruct sigaction *restrict\fR \fIoact\fR);
  17 .fi
  18 
  19 .SH DESCRIPTION
  20 .sp
  21 .LP
  22 The \fBsigaction()\fR function allows the calling process to examine or specify
  23 the action to be taken on delivery of a specific signal. See
  24 \fBsignal.h\fR(3HEAD) for an explanation of general signal concepts.
  25 .sp
  26 .LP
  27 The \fIsig\fR argument specifies the signal and can be assigned any of the
  28 signals specified in \fBsignal.h\fR(3HEAD) except  \fBSIGKILL\fR and
  29 \fBSIGSTOP\fR.
  30 .sp
  31 .LP
  32 If the argument \fIact\fR is not \fINULL\fR, it points to a structure
  33 specifying the new action to be taken when delivering \fIsig\fR. If the
  34 argument \fIoact\fR is not \fINULL\fR, it points to a structure where the
  35 action previously associated with \fIsig\fR is to be stored on return from
  36 \fBsigaction()\fR.
  37 .sp
  38 .LP
  39 The \fBsigaction\fR structure includes the following members:
  40 .sp


  87 .RE
  88 
  89 .sp
  90 .ne 2
  91 .na
  92 \fB\fBSA_RESETHAND\fR\fR
  93 .ad
  94 .RS 16n
  95 If set and the signal is caught, the disposition of the signal is reset to
  96 \fBSIG_DFL\fR and the signal will not be blocked on entry to the signal handler
  97 (\fBSIGILL\fR, \fBSIGTRAP\fR, and \fBSIGPWR\fR cannot be  automatically reset
  98 when delivered; the system silently enforces this restriction).
  99 .RE
 100 
 101 .sp
 102 .ne 2
 103 .na
 104 \fB\fBSA_NODEFER\fR\fR
 105 .ad
 106 .RS 16n
 107 If set and the signal is caught, the signal will not be automatically blocked
 108 by the kernel while it is being caught.


 109 .RE
 110 
 111 .sp
 112 .ne 2
 113 .na
 114 \fB\fBSA_RESTART\fR\fR
 115 .ad
 116 .RS 16n
 117 If set and the signal is caught, functions that are interrupted by the
 118 execution of this signal's handler are transparently restarted by the system,
 119 namely \fBfcntl\fR(2), \fBioctl\fR(2), \fBwait\fR(3C), \fBwaitid\fR(2), and the
 120 following functions on slow devices like terminals: \fBgetmsg()\fR and
 121 \fBgetpmsg()\fR (see \fBgetmsg\fR(2));  \fBputmsg()\fR and \fBputpmsg()\fR (see
 122 \fBputmsg\fR(2)); \fBpread()\fR, \fBread()\fR, and \fBreadv()\fR (see
 123 \fBread\fR(2)); \fBpwrite()\fR, \fBwrite()\fR, and \fBwritev()\fR (see
 124 \fBwrite\fR(2)); \fBrecv()\fR, \fBrecvfrom()\fR, and \fBrecvmsg()\fR (see
 125 \fBrecv\fR(3SOCKET)); and \fBsend()\fR, \fBsendto()\fR, and \fBsendmsg()\fR
 126 (see \fBsend\fR(3SOCKET)). Otherwise, the function returns an \fBEINTR\fR
 127 error.
 128 .RE


 150 .ad
 151 .RS 16n
 152 If set and \fIsig\fR equals  \fBSIGCHLD\fR, the system will not create zombie
 153 processes when children of the calling process exit. If the calling process
 154 subsequently issues a \fBwait\fR(3C), it blocks until all of the calling
 155 process's child processes terminate, and then returns \fB\(mi1\fR with
 156 \fBerrno\fR set to \fBECHILD\fR.
 157 .RE
 158 
 159 .sp
 160 .ne 2
 161 .na
 162 \fB\fBSA_NOCLDSTOP\fR\fR
 163 .ad
 164 .RS 16n
 165 If set and \fIsig\fR equals \fBSIGCHLD\fR, \fBSIGCHLD\fR will not be sent to
 166 the calling process when its child processes stop or continue.
 167 .RE
 168 
 169 .SH RETURN VALUES
 170 .sp
 171 .LP
 172 Upon successful completion, \fB0\fR is returned. Otherwise, \fB\(mi1\fR is
 173 returned, \fBerrno\fR is set to indicate the error, and no new signal handler
 174 is installed.
 175 .SH ERRORS
 176 .sp
 177 .LP
 178 The \fBsigaction()\fR function will fail if:
 179 .sp
 180 .ne 2
 181 .na
 182 \fB\fBEINVAL\fR\fR
 183 .ad
 184 .RS 10n
 185 The value of the \fIsig\fR argument is not a valid signal number or is equal to
 186 \fBSIGKILL\fR or \fBSIGSTOP\fR. In addition, if in a multithreaded process, it
 187 is equal to \fBSIGWAITING\fR, \fBSIGCANCEL\fR, or \fBSIGLWP\fR.
 188 .RE
 189 
 190 .SH ATTRIBUTES
 191 .sp
 192 .LP
 193 See \fBattributes\fR(5) for descriptions of the following attributes:
 194 .sp
 195 
 196 .sp
 197 .TS
 198 box;
 199 c | c
 200 l | l .
 201 ATTRIBUTE TYPE  ATTRIBUTE VALUE
 202 _
 203 Interface Stability     Committed
 204 _
 205 MT-Level        Async-Signal-Safe
 206 _
 207 Standard        See \fBstandards\fR(5).
 208 .TE
 209 
 210 .SH SEE ALSO
 211 .sp
 212 .LP
 213 \fBkill\fR(1), \fBIntro\fR(2), \fBexit\fR(2), \fBfcntl\fR(2), \fBgetmsg\fR(2),
 214 \fBioctl\fR(2), \fBkill\fR(2), \fBpause\fR(2), \fBputmsg\fR(2), \fBread\fR(2),
 215 \fBsigaltstack\fR(2), \fBsigprocmask\fR(2), \fBsigsend\fR(2),
 216 \fBsigsuspend\fR(2), \fBwaitid\fR(2), \fBwrite\fR(2), \fBrecv\fR(3SOCKET),
 217 \fBsend\fR(3SOCKET), \fBsiginfo.h\fR(3HEAD), \fBsignal\fR(3C),
 218 \fBsignal.h\fR(3HEAD), \fBsigsetops\fR(3C), \fBucontext.h\fR(3HEAD),
 219 \fBwait\fR(3C), \fBattributes\fR(5), \fBstandards\fR(5)
 220 .SH NOTES
 221 .sp
 222 .LP
 223 The handler routine can be declared:
 224 .sp
 225 .in +2
 226 .nf
 227 void handler (int \fIsig\fR, siginfo_t *\fIsip\fR, ucontext_t *\fIucp\fR);
 228 .fi
 229 .in -2
 230 
 231 .sp
 232 .LP
 233 The \fIsig\fR argument is the signal number. The \fIsip\fR argument is a
 234 pointer (to space on the stack) to a \fBsiginfo_t\fR structure, which provides
 235 additional detail about the delivery of the signal. The \fIucp\fR argument is a
 236 pointer (again to space on the stack) to a \fBucontext_t\fR structure (defined
 237 in <\fBsys/ucontext.h\fR>) which contains the context from before the signal.
 238 It is not recommended that \fIucp\fR be used by the handler to restore the
 239 context from before the signal delivery.
   1 '\" te
   2 .\" Copyright (c) 2014, Ryan Zezeski.  All Rights Reserved.
   3 .\" Copyright (c) 2007, Sun Microsystems, Inc.  All Rights Reserved.
   4 .\" Copyright 1989 AT&T
   5 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
   6 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
   7 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
   8 .TH SIGACTION 2 "Oct 22, 2014"
   9 .SH NAME
  10 sigaction \- detailed signal management
  11 .SH SYNOPSIS
  12 .LP
  13 .nf
  14 #include <signal.h>
  15 
  16 \fBint\fR \fBsigaction\fR(\fBint\fR \fIsig\fR, \fBconst struct sigaction *restrict\fR \fIact\fR,
  17      \fBstruct sigaction *restrict\fR \fIoact\fR);
  18 .fi
  19 
  20 .SH DESCRIPTION

  21 .LP
  22 The \fBsigaction()\fR function allows the calling process to examine or specify
  23 the action to be taken on delivery of a specific signal. See
  24 \fBsignal.h\fR(3HEAD) for an explanation of general signal concepts.
  25 .sp
  26 .LP
  27 The \fIsig\fR argument specifies the signal and can be assigned any of the
  28 signals specified in \fBsignal.h\fR(3HEAD) except  \fBSIGKILL\fR and
  29 \fBSIGSTOP\fR.
  30 .sp
  31 .LP
  32 If the argument \fIact\fR is not \fINULL\fR, it points to a structure
  33 specifying the new action to be taken when delivering \fIsig\fR. If the
  34 argument \fIoact\fR is not \fINULL\fR, it points to a structure where the
  35 action previously associated with \fIsig\fR is to be stored on return from
  36 \fBsigaction()\fR.
  37 .sp
  38 .LP
  39 The \fBsigaction\fR structure includes the following members:
  40 .sp


  87 .RE
  88 
  89 .sp
  90 .ne 2
  91 .na
  92 \fB\fBSA_RESETHAND\fR\fR
  93 .ad
  94 .RS 16n
  95 If set and the signal is caught, the disposition of the signal is reset to
  96 \fBSIG_DFL\fR and the signal will not be blocked on entry to the signal handler
  97 (\fBSIGILL\fR, \fBSIGTRAP\fR, and \fBSIGPWR\fR cannot be  automatically reset
  98 when delivered; the system silently enforces this restriction).
  99 .RE
 100 
 101 .sp
 102 .ne 2
 103 .na
 104 \fB\fBSA_NODEFER\fR\fR
 105 .ad
 106 .RS 16n
 107 If set and the signal is caught, the signal will not be automatically
 108 blocked by the kernel while it is being caught.  Unless the signal is
 109 a realtime signal.  Multiple instances of the same realtime signal
 110 must be delivered in FIFO order and thus are always deferred.
 111 .RE
 112 
 113 .sp
 114 .ne 2
 115 .na
 116 \fB\fBSA_RESTART\fR\fR
 117 .ad
 118 .RS 16n
 119 If set and the signal is caught, functions that are interrupted by the
 120 execution of this signal's handler are transparently restarted by the system,
 121 namely \fBfcntl\fR(2), \fBioctl\fR(2), \fBwait\fR(3C), \fBwaitid\fR(2), and the
 122 following functions on slow devices like terminals: \fBgetmsg()\fR and
 123 \fBgetpmsg()\fR (see \fBgetmsg\fR(2));  \fBputmsg()\fR and \fBputpmsg()\fR (see
 124 \fBputmsg\fR(2)); \fBpread()\fR, \fBread()\fR, and \fBreadv()\fR (see
 125 \fBread\fR(2)); \fBpwrite()\fR, \fBwrite()\fR, and \fBwritev()\fR (see
 126 \fBwrite\fR(2)); \fBrecv()\fR, \fBrecvfrom()\fR, and \fBrecvmsg()\fR (see
 127 \fBrecv\fR(3SOCKET)); and \fBsend()\fR, \fBsendto()\fR, and \fBsendmsg()\fR
 128 (see \fBsend\fR(3SOCKET)). Otherwise, the function returns an \fBEINTR\fR
 129 error.
 130 .RE


 152 .ad
 153 .RS 16n
 154 If set and \fIsig\fR equals  \fBSIGCHLD\fR, the system will not create zombie
 155 processes when children of the calling process exit. If the calling process
 156 subsequently issues a \fBwait\fR(3C), it blocks until all of the calling
 157 process's child processes terminate, and then returns \fB\(mi1\fR with
 158 \fBerrno\fR set to \fBECHILD\fR.
 159 .RE
 160 
 161 .sp
 162 .ne 2
 163 .na
 164 \fB\fBSA_NOCLDSTOP\fR\fR
 165 .ad
 166 .RS 16n
 167 If set and \fIsig\fR equals \fBSIGCHLD\fR, \fBSIGCHLD\fR will not be sent to
 168 the calling process when its child processes stop or continue.
 169 .RE
 170 
 171 .SH RETURN VALUES

 172 .LP
 173 Upon successful completion, \fB0\fR is returned. Otherwise, \fB\(mi1\fR is
 174 returned, \fBerrno\fR is set to indicate the error, and no new signal handler
 175 is installed.
 176 .SH ERRORS

 177 .LP
 178 The \fBsigaction()\fR function will fail if:
 179 .sp
 180 .ne 2
 181 .na
 182 \fB\fBEINVAL\fR\fR
 183 .ad
 184 .RS 10n
 185 The value of the \fIsig\fR argument is not a valid signal number or is equal to
 186 \fBSIGKILL\fR or \fBSIGSTOP\fR. In addition, if in a multithreaded process, it
 187 is equal to \fBSIGWAITING\fR, \fBSIGCANCEL\fR, or \fBSIGLWP\fR.
 188 .RE
 189 
 190 .SH ATTRIBUTES

 191 .LP
 192 See \fBattributes\fR(5) for descriptions of the following attributes:
 193 .sp
 194 
 195 .sp
 196 .TS
 197 box;
 198 c | c
 199 l | l .
 200 ATTRIBUTE TYPE  ATTRIBUTE VALUE
 201 _
 202 Interface Stability     Committed
 203 _
 204 MT-Level        Async-Signal-Safe
 205 _
 206 Standard        See \fBstandards\fR(5).
 207 .TE
 208 
 209 .SH SEE ALSO

 210 .LP
 211 \fBkill\fR(1), \fBIntro\fR(2), \fBexit\fR(2), \fBfcntl\fR(2), \fBgetmsg\fR(2),
 212 \fBioctl\fR(2), \fBkill\fR(2), \fBpause\fR(2), \fBputmsg\fR(2), \fBread\fR(2),
 213 \fBsigaltstack\fR(2), \fBsigprocmask\fR(2), \fBsigsend\fR(2),
 214 \fBsigsuspend\fR(2), \fBwaitid\fR(2), \fBwrite\fR(2), \fBrecv\fR(3SOCKET),
 215 \fBsend\fR(3SOCKET), \fBsiginfo.h\fR(3HEAD), \fBsignal\fR(3C),
 216 \fBsignal.h\fR(3HEAD), \fBsigsetops\fR(3C), \fBucontext.h\fR(3HEAD),
 217 \fBwait\fR(3C), \fBattributes\fR(5), \fBstandards\fR(5)
 218 .SH NOTES

 219 .LP
 220 The handler routine can be declared:
 221 .sp
 222 .in +2
 223 .nf
 224 void handler (int \fIsig\fR, siginfo_t *\fIsip\fR, ucontext_t *\fIucp\fR);
 225 .fi
 226 .in -2
 227 
 228 .sp
 229 .LP
 230 The \fIsig\fR argument is the signal number. The \fIsip\fR argument is a
 231 pointer (to space on the stack) to a \fBsiginfo_t\fR structure, which provides
 232 additional detail about the delivery of the signal. The \fIucp\fR argument is a
 233 pointer (again to space on the stack) to a \fBucontext_t\fR structure (defined
 234 in <\fBsys/ucontext.h\fR>) which contains the context from before the signal.
 235 It is not recommended that \fIucp\fR be used by the handler to restore the
 236 context from before the signal delivery.