sys_sigaltstack [aach/i386/kernel/signal.c]
Allows a process to define a new alternate signal stack and/or retrieve the state of an existing alternate signal stack. An alternate signal stack is used during the execution of a signal handler if the establishment of that handler (see sys_sigaction) requested it. The most common usage of an alternate signal stack is to handle the SIGSEGV signal that is generated if the space available for the normal process stack is exhausted: in this case, a signal handler for SIGSEGV cannot be invoked on the process stack; if we wish to handle it, we must use an alternate signal stack. Establishing an alternate signal stack is useful if a process expects that it may exhaust its standard stack. This may occur, for example, because the stack grows so large that it encounters the upwardly growing heap, or it reaches a limit established by a call to sys_setrlimit with ebx=RLIMIT_STACK. If the standard stack is exhausted, the kernel sends the process a SIGSEGV signal. In these circumstances the only way to catch this signal is on an alternate signal stack. On most hardware architectures supported by Linux, stacks grow downwards. sys_sigaltstack automatically takes account of the direction of stack growth. Functions called from a signal handler executing on an alternate signal stack will also use the alternate signal stack. (This also applies to any handlers invoked for other signals while the process is executing on the alternate signal stack.) Unlike the standard stack, the system does not automatically extend the alternate signal stack. Exceeding the allocated size of the alternate signal stack will lead to unpredictable results. A successful call to sys_execve removes any existing alternate signal stack. Arguments
eax | 186
ebx | Pointer to a sigaltstack structure specifying the new alternate signal stack (this argument may be 0) :
`struc sigaltstack { ss_sp rd 1 ss_flags rd 1 ss_size rd 1 }`
`sigaltstack members: ss_sp` `Base address of stack. When a signal handler is invoked on the alternate stack, the kernel automatically aligns the address given in sigaltstack.ss_sp to a suitable address boundary for the underlying hardware architecture.` `ss_flags` `Flags.`
`0` | `Establish a new alternate signal stack.`
`SS_DISABLE` | `Disable an existing stack. In this case remaining fields of sigaltstack are ignored.`
`ss_size` `Size of the stack (in bytes).`
ecx | Pointer to a sigaltstack structure which will be used to retrieve information about the currently established signal stack or about the stack that was in effect prior to the call to sys_sigaltstack (This argument may be 0.):
`struc sigaltstack { ss_sp rd 1 ss_flags rd 1 ss_size rd 1 }`
`sigaltstack members: ss_sp` `Base address of stack.` `ss_flags` `Flags.`
`SS_ONSTACK` | `The process is currently executing on the alternate signal stack. (Note that it is not possible to change the alternate signal stack if the process is currently executing on it.)`
`SS_DISABLE` | `The alternate signal stack is currently disabled.`
`ss_size` `Size of the stack (in bytes).`
Return values If the system call succeeds the return value is 0. If the system call fails the return value is one of the following errno values:
`-EFAULT` | `Either ebx or ecx is not NULL and points to an area outside of the process's address space.`
`-EINVAL` | `ebx is not NULL and the ss_flags field contains a non-zero value other than SS_DISABLE.`
`-ENOMEM` | `The specified size of the new alternate signal stack (stack_t.ss_size) was less than MINSTKSZ.`
`-EPERM` | `An attempt was made to change the alternate signal stack while it was active (i.e., the process was already executing on the current alternate signal stack).`
Remarks The normal sequence of events for using an alternate signal stack is the following: Allocate an area of memory to be used for the alternate signal stack. Use sys_sigaltstack to inform the system of the existence and location of the alternate signal stack. When establishing a signal handler using sys_sigaction, inform the system that the signal handler should be executed on the alternate signal stack by specifying the SA_ONSTACK flag. Compatibility n/a