|
|
Applications that maintain complex or fixed-size stacks can use the call
struct sigaltstack { caddr_t ss_sp; int ss_size; int ss_flags; };
sigaltstack(ss, oss) struct sigaltstack *ss; struct sigaltstack *oss;to provide the system with a stack based at ss_sp of size ss_size for delivery of signals. The system automatically adjusts for direction of stack growth. The member ss_flags indicates whether the process is currently on the signal stack and whether the signal stack is disabled.
When a signal is to be delivered and the process has requested that it be delivered on the alternate stack, the system checks whether the process is on a signal stack (see sigaction(2)). If it is not, then the process is switched to the signal stack for delivery, with the return from the signal arranged to restore the previous stack.
If the process wishes to take a non-local exit from the signal-handling routine or run code from the signal stack that uses a different stack, a sigaltstack call should be used to reset the signal stack (see sigaltstack(2)).