From 3cbfb6821b8355850a37cae5eaa9578c55fd8392 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Tue, 1 Mar 2016 13:34:15 +0200 Subject: [PATCH] Cleaned up SIGTERM and SIGINT handlers Changed fprintf to write since it is signal safe. --- server/core/gateway.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/core/gateway.c b/server/core/gateway.c index 9dc266aef..006bcbcf0 100644 --- a/server/core/gateway.c +++ b/server/core/gateway.c @@ -293,11 +293,13 @@ static void sigusr1_handler (int i) mxs_log_rotate(); } +static const char shutdown_msg[] = "\n\nShutting down MaxScale\n\n"; + static void sigterm_handler(int i) { last_signal = i; shutdown_server(); - fprintf(stderr, "\n\nShutting down MaxScale\n\n"); + write(STDERR_FILENO, shutdown_msg, sizeof(shutdown_msg)); } static void @@ -305,7 +307,7 @@ sigint_handler(int i) { last_signal = i; shutdown_server(); - fprintf(stderr, "\n\nShutting down MaxScale\n\n"); + write(STDERR_FILENO, shutdown_msg, sizeof(shutdown_msg)); } static void