From 2fa35c7316c26a469c0076a1a98c0b0a715b3386 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 19 Mar 2015 08:29:51 +0000 Subject: [PATCH] lib/core: Silence internally used signals We use SIGTERM to kill off child processes. We use it a lot. Reporting everytime we use it is just spam. Treat the similar user signals (SIGINT, SIGQUIT and the should-never-have-been SIGPIPE) similarly to reduce noise. Signed-off-by: Chris Wilson Cc: Thomas Wood --- lib/igt_core.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/igt_core.c b/lib/igt_core.c index 962b878c..61b3a338 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -1304,9 +1304,12 @@ static igt_exit_handler_t exit_handler_fn[MAX_EXIT_HANDLERS]; static bool exit_handler_disabled; static sigset_t saved_sig_mask; #define SIGDEF(x) { x, #x, sizeof(#x) - 1 } +#define SILENT(x) { x, NULL, 0 } static const struct { int number; const char *name; size_t name_len; } handled_signals[] = - { SIGDEF(SIGINT), SIGDEF(SIGHUP), SIGDEF(SIGTERM), SIGDEF(SIGQUIT), - SIGDEF(SIGPIPE), SIGDEF(SIGABRT), SIGDEF(SIGSEGV), SIGDEF(SIGBUS) }; + { SILENT(SIGINT), SILENT(SIGHUP), SILENT(SIGTERM), SILENT(SIGQUIT), + SILENT(SIGPIPE), SIGDEF(SIGABRT), SIGDEF(SIGSEGV), SIGDEF(SIGBUS) }; +#undef SILENT +#undef SIGDEF static int install_sig_handler(int sig_num, sighandler_t handler) { @@ -1364,13 +1367,17 @@ static void fatal_sig_handler(int sig) restore_all_sig_handler(); for (i = 0; i < ARRAY_SIZE(handled_signals); i++) { - if (handled_signals[i].number == sig) { + if (handled_signals[i].number != sig) + continue; + + if (handled_signals[i].name_len) { write(STDERR_FILENO, "Received signal ", 16); write(STDERR_FILENO, handled_signals[i].name, handled_signals[i].name_len); write(STDERR_FILENO, ".\n", 2); - break; } + + break; } /*