diff --git a/man2/sigaltstack.2 b/man2/sigaltstack.2 index 189db1b3a..38342ef0e 100644 --- a/man2/sigaltstack.2 +++ b/man2/sigaltstack.2 @@ -288,7 +288,13 @@ different struct, and had the major disadvantage that the caller had to know the direction of stack growth. .SH EXAMPLE The following code segment demonstrates the use of -.BR sigaltstack (): +.BR sigaltstack () +(and +.BR sigaction (2)) +to install an alternate signal stack that is employed by a handler +for the +.BR SIGSEGV +signal: .PP .in +4n .EX @@ -306,6 +312,14 @@ if (sigaltstack(&ss, NULL) == \-1) perror("sigaltstack"); exit(EXIT_FAILURE); } + +sa.sa_flags = SA_ONSTACK; +sa.sa_handler = handler(); /* Address of a signal handler */ +sigemptyset(&sa.sa_mask); +if (sigaction(SIGSEGV, &sa, NULL) == -1) { + perror("sigaction"); + exit(EXIT_FAILURE); +} .EE .in .SH BUGS