int sigaltstack(const stack_t *ss, stack_t *oss);
The normal sequence of events for using an alternate signal stack is the following:
typedef struct {
void *ss_sp; /* Base address of stack */
int ss_flags; /* Flags */
size_t ss_size; /* Number of bytes in stack */
} stack_t;
To establish a new alternate signal stack, ss.ss_flags is set to zero, and ss.sp_sp and ss.ss_size specify the starting address and size of the stack. The constant SIGSTKSZ is defined to be large enough to cover the usual size requirements for an alternate signal stack, and the constant MINSIGSTKSZ defines the minimum size required to execute a signal handler.
To disable an existing stack, specify ss.ss_flags as SS_DISABLE. In this case, the remaining fields in ss are ignored.
If oss is not NULL, then it is used to return information about the alternate signal stack which was in effect prior to the call to sigaltstack. The oss.ss_sp and oss.ss_size fields return the starting address and size of that stack. The oss.ss_flags may return either of the following values:
stack_t ss;
ss.ss_sp = malloc(SIGSTKSZ);
if (ss.ss_sp == NULL)
/* Handle error */;
ss.ss_size = SIGSTKSZ;
ss.ss_flags = 0;
if (sigaltstack(&ss, NULL) == -1)
/* Handle error */;