sigaction.2: Minor tweaks to the code example

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Michael Kerrisk 2021-08-09 02:19:43 +02:00
parent 1875f17753
commit ef0350ce4c
1 changed files with 5 additions and 5 deletions

View File

@ -1161,9 +1161,9 @@ handler(int signo, siginfo_t *info, void *context)
{ {
struct sigaction oldact; struct sigaction oldact;
if (sigaction(SIGSEGV, NULL, &oldact) != 0 || if (sigaction(SIGSEGV, NULL, &oldact) == \-1 ||
(oldact.sa_flags & SA_UNSUPPORTED) || (oldact.sa_flags & SA_UNSUPPORTED) ||
!(oldact.sa_flags & SA_EXPOSE_TAGBITS)) { !(oldact.sa_flags & SA_EXPOSE_TAGBITS)) {
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);
} }
_exit(EXIT_SUCCESS); _exit(EXIT_SUCCESS);
@ -1172,11 +1172,11 @@ handler(int signo, siginfo_t *info, void *context)
int int
main(void) main(void)
{ {
struct sigaction act = {0}; struct sigaction act = { 0 };
act.sa_flags = SA_SIGINFO | SA_UNSUPPORTED | SA_EXPOSE_TAGBITS; act.sa_flags = SA_SIGINFO | SA_UNSUPPORTED | SA_EXPOSE_TAGBITS;
act.sa_sigaction = &handler; act.sa_sigaction = &handler;
if (sigaction(SIGSEGV, &act, NULL) != 0) { if (sigaction(SIGSEGV, &act, NULL) == \-1) {
perror("sigaction"); perror("sigaction");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }