The Linux Programming Interface

(nextflipdebug5) #1

446 Chapter 21


We can use sigaltstack() to define an alternate signal stack for a process. This is
an area of memory that is used instead of the standard process stack when invoking
a signal handler. An alternate signal stack is useful in cases where the standard
stack has been exhausted by growing too large (at which point the kernel sends a
SIGSEGV signal to the process).
The sigaction() SA_SIGINFO flag allows us to establish a signal handler that
receives additional information about a signal. This information is supplied via a
siginfo_t structure whose address is passed as an argument to the signal handler.
When a signal handler interrupts a blocked system call, the system call fails
with the error EINTR. We can take advantage of this behavior to, for example, set a
timer on a blocking system call. Interrupted system calls can be manually restarted
if desired. Alternatively, establishing the signal handler with the sigaction()
SA_RESTART flag causes many (but not all) system calls to be automatically restarted.

Further information
See the sources listed in Section 20.15.

21.7 Exercise


21-1. Implement abort().
Free download pdf