sigspace(2)
NAME
sigspace − assure sufficient signal stack space
SYNOPSIS
#include <signal.h>
size_t sigspace(size_t stacksize);
DESCRIPTION
sigspace() requests additional stack space that is guaranteed to be available for processing signals received by the calling process.
If the value of stacksize is positive, it specifies the size of a space, in bytes, which the system guarantees to be available when processing a signal. If the value of stacksize is zero, any guarantee of space is removed. If the value is negative, the guarantee is left unchanged; this can be used to interrogate the current guaranteed value.
When a signal’s action indicates that its handler should use the guaranteed space (specified with a sigaction(), sigvector(), or sigvec() call (see bsdproc(2)), the system checks to see if the process is currently using that space. If the process is not currently using that space, the system arranges for that space to be available for the duration of the signal handler’s execution. If that space has already been made available (due to a previous signal) no change is made. Normal stack discipline is resumed when the signal handler first using the guaranteed space is exited.
The guaranteed space is inherited by child processes resulting from a successful fork() system call, but the guarantee of space is removed after any exec() system call (see fork(2) and exec(2)).
The guaranteed space cannot be increased in size automatically, as is done for the normal stack. If the stack overflows the guaranteed space, the resulting behavior of the process is undefined.
Guaranteeing space for a stack can interfere with other memory allocation routines in an implementation-dependent manner.
During normal execution of the program the system checks for possible overflow of the stack. Guaranteeing space might cause the space available for normal execution to be reduced.
Leaving the context of a service routine abnormally, such as by longjmp() (see setjmp(3C)), removes the guarantee that the ordinary execution of the program will not extend into the guaranteed space. It might also cause the program to lose forever its ability to automatically increase the stack size, causing the program to be limited to the guaranteed space.
RETURN VALUE
Upon successful completion, sigspace() returns the size of the former guaranteed space. Otherwise, it returns −1 and sets errno to indicate the error.
ERRORS
sigspace() fails and the guaranteed amount of space remains unchanged if the following occurs:
[ENOMEM] The requested space cannot be guaranteed, either because of hardware limitations or because some software-imposed limit would be exceeded.
WARNINGS
The guaranteed space is allocated using malloc(3C). This use might interfere with other heap management mechanisms.
Methods for calculating the required size are not well developed.
Do not use sigspace() in conjunction with the facilities described under sigset(2V).
Do not use sigspace() in conjunction with sigstack(2).
DEPENDENCIES
Series 300/400
The kernel overhead taken in the reserved space is 608 bytes on Series 300/400 systems. This overhead must be included in the requested amount. These values are subject to change in future releases.
AUTHOR
sigspace() was developed by HP.
SEE ALSO
sigaction(2), sigstack(2), sigvector(2), malloc(3C), setjmp(3C).
Hewlett-Packard Company — HP-UX Release 9.0: August 1992