Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

sigstack - set or query alternative stack for signal

&pagelevel(4)&pagelevel

Syntax

#include <signal.h>

int sigstack (struct sigstack *ss, struct sigstack *oss);

Description

sigstack() can be used to define an alternative stack, called a signal stack, in which the
signals are processed. If the action of a signal indicates that the processing routine is to be
executed in a signal stack (specified by a sigaction() call), the system checks whether
the process is currently being executed in this stack. If the process is not being executed in
the signal stack, the system switches over to the signal stack until the signal-handling
routine terminates.

A signal stack is specified by a sigstack structure which contains the following elements:

char *ss_sp; / * pointer of signal stack */

int ss_onstack; / * current status */

ss_sp is the start address of the stack. If the ss_onstack field is non-zero, the signal stack is
to be activated.

If ss is not a null pointer, sigstack() sets the status of the signal stack to the value in the
sigstack structure to which ss points. The length of the stack must be at least SIGSTKSZ
bytes. If ss_onstack is non-zero, the system assumes that the process is being executed in
the signal stack. If ss is a null pointer, the status of the signal stack remains unchanged. If
oss is not a null pointer, the current status of the signal stack is saved in the sigstack
structure to which oss points.

Return val.

0

-1

if successful.

if an error occurs. errno is set to indicate the error.

Errors

sigstack() will fail if:

EPERM       an attempt was made to modify an active stack

Notes

Signal stacks are not automatically enlarged like normal stacks. Therefore, an overflow of
the signal stack can cause unexpected results.

Portable applications should use sigaltstack() instead of sigstack().

Programs should not terminate a signal-handling routine with longjmp() if it is executed in
a stack that was set up with sigstack(). In certain circumstances this stack can become
unusable. You are therefore advised to use the functions siglongjmp(), setcontext()
or swapcontext() in this case.