mirror of https://github.com/mkerrisk/man-pages
sigaltstack.2: Add use os sigaction() to example code
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
parent
93c33be846
commit
c854094fc0
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue