sigaltstack()

QNX SDP8.0C Library ReferenceAPIDeveloper

Set and get an alternate signal stack

Synopsis:

   
#include <signal.h>
                
int sigaltstack(const stack_t *restrict ss, 
                      stack_t *restrict oss);
            

Arguments:

ss
A pointer to a stack_t structure that provides the base address and size of a new signal stack, if ss is non-NULL.
If the ss_flags member is set to SS_DISABLE, any existing signal stack for the thread is removed and the ss_sp and ss_size members are ignored. Otherwise, the stack is enabled and values for ss_sp and ss_size members are set.
oss
A pointer to a stack_t structure that holds the current signal stack values for the thread, if oss is non-NULL. The ss_flags member may contain one of the following values:
SS_ONSTACK
The process is executing on the alternate signal stack. Any attempt to modify the alternate signal stack during exectution fails.
SS_DISABLE
The alternate signal stack is disabled.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The sigaltstack() function allows the current thread to define an alternate signal stack for signal handlers.

When the calling thread receives a signal and calls a signal handler registered with the SA_ONSTACK flag (see struct_sigaction), the alternate signal stack is used instead of the thread's regular stack to call the signal handler. For example, this could be useful for handling a SIGSEGV due to stack overflow.

The stack_t structure pointed to by the arguments of this function is defined in the <signal.h> header. The structure includes at least the following members:
ss_sp
The address of the stack.
ss_size
The size of the stack (in bytes). You must supply at least the value MINSIGSTKSZ but should supply at least the value MINSIGSTKSZ plus the stack requirement for the signal-handling code.
ss_flags
The state of the stack.

Returns:

0
Success.
-1
An error occurred; errno is set to indicate the error.

Errors:

EINVAL
The value of ss is a non-NULL pointer and points to a ss_flags member that contains flags other than SS_DISABLE.
ENOMEM
The size of the alternate stack area is less than MINSIGSTKSZ.
EPERM
An attempt was made to modify an active stack.
EFAULT
The supplied stack isn't within the process boundaries.

Classification:

POSIX 1003.1

Safety:
Cancellation point No
Signal handler Yes
Thread Yes
Page updated: