4 .\" The contents of this file are subject to the terms of the
5 .\" Common Development and Distribution License (the "License").
6 .\" You may not use this file except in compliance with the License.
8 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 .\" or http://www.opensolaris.org/os/licensing.
10 .\" See the License for the specific language governing permissions
11 .\" and limitations under the License.
13 .\" When distributing Covered Code, include this CDDL HEADER in each
14 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 .\" If applicable, add the following below this CDDL HEADER, with the
16 .\" fields enclosed by brackets "[]" replaced with your own identifying
17 .\" information: Portions Copyright [yyyy] [name of copyright owner]
21 .\" Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
24 .TH stackoverflow_install_handler 3 "13 Jan 2009" "SunOS 5.11"
26 stackoverflow_install_handler, stackoverflow_deinstall_handler \- Installs and deinstall a stack overflow handler
30 #include <\fBsigsegv.h\fR>
32 int \fBstackoverflow_install_handler\fR (\fIstackoverflow_handler_t\fR
34 \fIhandler\fR, \fIvoid* extra_stack\fR,
37 \fIunsigned long extra_stack_size\fR);
40 void \fBstackoverflow_deinstall_handler\fR (\fIvoid\fR);
45 In some applications, the \fBstack\fR \fBoverflow\fR \fBhandler\fR performs some cleanup or notifies the user and then immediately terminates the application. In other applications, the \fBstack\fR \fBoverflow\fR \fBhandler\fR longjmps back to a central point in the application. This library supports both uses. In the second case, the handler must ensure to restore the normal signal mask (because many signals are blocked while the handler is executed), and must also call \fBsigsegv_leave_handler()\fR to transfer control; then only it can longjmp away.
48 The handler is run at a moment when nothing about the global state of the program is known. Therefore it cannot use facilities that manipulate global variables or locks. In particular, it cannot use malloc(); use mmap() Instead. It cannot use fopen(); use open() instead. Etc. All global variables that are accessed by the handler should be mark
54 typedef void (*\fBstackoverflow_handler_t\fR) (\fIint emergency\fR,
56 \fIstackoverflow_context_t scp\fR);
59 \fIStackoverflow_handler_t\fR is the type of a stack overflow handler. Such a handler should perform a longjmp call in order to reduce the amount of stack needed. It must not return.The \fIemergency\fR argument is 0 when the stack could be repared, or 1 if the application should better save its state and exit now.
62 The \fIextra_stack\fR argument is a pointer to a preallocated area used as a stack for executing the handler. It is typically allocated by use of `alloca' during `main'. Its size should be sufficiently large.
65 The \fIextra_stack_size\fR is the size of the extra_stack argument.
70 If success, \fBstackoverflow_install_handler()\fR returns 0 on success, or -1 if the system doesn't support catching stack overflow.
76 \fattributes\fR(5), \fBsigsegv\fR(3), \fBstandards\fR(5)