From 9a804293f9ace6c6044f6bee187925fabf8d34c7 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Wed, 1 May 2024 00:00:21 +0100 Subject: [PATCH] stress-sigfpe: handle unexpected SIGILL signals 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 --- stress-sigfpe.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/stress-sigfpe.c b/stress-sigfpe.c index cd7f8edf4..fbf4a5b03 100644 --- a/stress-sigfpe.c +++ b/stress-sigfpe.c @@ -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);