Skip to content

Commit

Permalink
stress-sigfpe: handle unexpected SIGILL signals
Browse files Browse the repository at this point in the history
Some libc math libs may throw SIGILL on division by zero,
the C spec says the behaviour is undefined, so catch these
weird SIGILL behaviours just in case.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
  • Loading branch information
ColinIanKing committed Apr 30, 2024
1 parent ace0340 commit 9a80429
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions stress-sigfpe.c
Expand Up @@ -229,6 +229,16 @@ static int stress_sigfpe(stress_args_t *args)
args->name, errno, strerror(errno));
return EXIT_FAILURE;
}
/*
* division by zero is undefined, some C libs
* may even throw SIGILL, so catch these.
*/
ret = sigaction(SIGILL, &action, NULL);
if (ret < 0) {
pr_err("%s: sigaction SIGILL: errno=%d (%s)\n",
args->name, errno, strerror(errno));
return EXIT_FAILURE;
}

(void)alarm(0);
stress_set_proc_state(args->name, STRESS_STATE_RUN);
Expand Down

0 comments on commit 9a80429

Please sign in to comment.