CDDL HEADER START
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.
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.
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]
CDDL HEADER END
Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
handler, void* extra_stack,
unsigned long extra_stack_size);
In some applications, the stack overflow handler performs some cleanup or notifies the user and then immediately terminates the application. In other applications, the stack overflow handler 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 sigsegv_leave_handler() to transfer control; then only it can longjmp away.
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 'volatile'.
typedef void (*stackoverflow_handler_t) (int emergency,
stackoverflow_context_t scp);
The extra_stack 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.
The extra_stack_size is the size of the extra_stack argument.
If success, stackoverflow_install_handler() returns 0 on success, or -1 if the system doesn't support catching stack overflow.
\fattributes(5), sigsegv(3), standards(5)