Unleashed v1.4
[unleashed.git] / share / man / man3c / sigstack.3c
blob835a955e8dd71eddcd9d2ce043411d969daf326a
1 .\"
2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
6 .\"
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
9 .\" documentation.
10 .\"
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
13 .\"
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group.  In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document.  The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
24 .\"
25 .\" This notice shall appear on any product containing this material.
26 .\"
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
30 .\"
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
35 .\"
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
41 .\"
42 .\"
43 .\" Copyright (c) 1992, X/Open Company Limited.  All Rights Reserved.
44 .\" Portions Copyright (c) 1996, Sun Microsystems, Inc.  All Rights Reserved
45 .\"
46 .TH SIGSTACK 3C "Feb 28, 1996"
47 .SH NAME
48 sigstack \- set and/or get alternate signal stack context
49 .SH SYNOPSIS
50 .LP
51 .nf
52 #include <signal.h>
54 \fBint\fR \fBsigstack\fR(\fBstruct sigstack *\fR\fIss\fR, \fBstruct sigstack *\fR\fIoss\fR);
55 .fi
57 .SH DESCRIPTION
58 .sp
59 .LP
60 The \fBsigstack()\fR function allows the calling process to indicate to the
61 system an area of its address space to be used for processing signals received
62 by the process.
63 .sp
64 .LP
65 If the \fIss\fR argument is not a null pointer, it must point to a
66 \fBsigstack\fR structure. The length of the application-supplied stack must be
67 at least \fBSIGSTKSZ\fR bytes. If the alternate signal stack overflows, the
68 resulting behavior is undefined.  (See \fBUSAGE\fR below.)
69 .RS +4
70 .TP
71 .ie t \(bu
72 .el o
73 The value of the \fBss_onstack\fR member indicates whether the process wants
74 the system to use an alternate signal stack when delivering signals.
75 .RE
76 .RS +4
77 .TP
78 .ie t \(bu
79 .el o
80 The value of the \fBss_sp\fR member indicates the desired location of the
81 alternate signal stack area in the process' address space.
82 .RE
83 .RS +4
84 .TP
85 .ie t \(bu
86 .el o
87 If the \fIss\fR argument is a null pointer, the current alternate signal stack
88 context is not changed.
89 .RE
90 .sp
91 .LP
92 If the \fIoss\fR argument is not a null pointer, it points to a \fBsigstack\fR
93 structure in which the current alternate signal stack context is placed.  The
94 value stored in the \fBss_onstack\fR member of \fIoss\fR will be non-zero if
95 the process is currently executing on the alternate signal stack.  If the
96 \fIoss\fR argument is a null pointer, the current alternate signal stack
97 context is not returned.
98 .sp
99 .LP
100 When a signal's action indicates its handler should execute on the alternate
101 signal stack (specified by calling \fBsigaction\fR(2)), \fBsigstack()\fR checks
102 to see if the process is currently executing on that stack.  If the process is
103 not currently executing on the alternate signal stack, the system arranges a
104 switch to the alternate signal stack for the duration of the signal handler's
105 execution.
108 After a successful call to one of the \fIexec\fR functions, there are no
109 alternate signal stacks in the new process image.
110 .SH RETURN VALUES
113 Upon successful completion, \fBsigstack()\fR returns \fB0\fR.  Otherwise, it
114 returns \fB\(mi1\fR and sets \fBerrno\fR to indicate the error.
115 .SH ERRORS
118 The \fBsigstack()\fR function will fail if:
120 .ne 2
122 \fB\fBEPERM\fR\fR
124 .RS 9n
125 An attempt was made to modify an active stack.
128 .SH USAGE
131 A portable application, when being written or rewritten, should use
132 \fBsigaltstack\fR(2) instead of \fBsigstack()\fR.
135 The direction of stack growth is not indicated in the historical definition of
136 \fBstruct sigstack\fR. The only way to portably establish a stack pointer is
137 for the application to determine stack growth direction, or to allocate a block
138 of storage and set the stack pointer to the middle. \fBsigstack()\fR may assume
139 that the size of the signal stack is \fBSIGSTKSZ\fR as found in
140 <\fBsignal.h\fR>. An application that would like to specify a signal stack size
141 other than \fBSIGSTKSZ\fR should use \fBsigaltstack\fR(2).
144 Applications should not use \fBlongjmp\fR(3C) to leave a signal handler that is
145 running on a stack established with \fBsigstack()\fR. Doing so may disable
146 future use of the signal stack.  For abnormal exit from a signal handler,
147 \fBsiglongjmp\fR(3C), \fBsetcontext\fR(2), or \fBswapcontext\fR(3C) may be
148 used. These functions fully support switching from one stack to another.
151 The \fBsigstack()\fR function requires the application to have knowledge of the
152 underlying system's stack architecture.  For this reason, \fBsigaltstack\fR(2)
153 is recommended over this function.
154 .SH SEE ALSO
157 \fBfork\fR(2), \fB_longjmp\fR(3C), \fBlongjmp\fR(3C), \fBsetjmp\fR(3C),
158 \fBsigaltstack\fR(2), \fBsiglongjmp\fR(3C), \fBsigsetjmp\fR(3C)