From 17d0bf6454123d2991ff1b4449ae8e95a8e4c10d Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 27 Mar 2007 10:28:45 +0000 Subject: [PATCH] * qemud/qemud.c: If using FORTIFY_SOURCE, remove warning warn_unused_result by counting errors found in signal handler and logging them in the main loop. --- ChangeLog | 6 ++++++ qemud/qemud.c | 21 ++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 107600214a..f354109078 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Tue Mar 27 11:26:00 BST 2007 Richard W.M. Jones + + * qemud/qemud.c: If using FORTIFY_SOURCE, remove warning + warn_unused_result by counting errors found in signal + handler and logging them in the main loop. + Mon Mar 26 11:29:43 CEST 2007 Daniel Veillard * acinclude.m4: applied patch from Jim Meyering to avoid clobbering diff --git a/qemud/qemud.c b/qemud/qemud.c index 30245b195a..12b112c4c1 100644 --- a/qemud/qemud.c +++ b/qemud/qemud.c @@ -57,15 +57,23 @@ static int godaemon = 0; static int verbose = 0; static int sigwrite = -1; +static sig_atomic_t sig_errors = 0; +static int sig_lasterrno = 0; + static void sig_handler(int sig) { unsigned char sigc = sig; int origerrno; + int r; if (sig == SIGCHLD) /* We explicitly waitpid the child later */ return; origerrno = errno; - write(sigwrite, &sigc, 1); + r = write(sigwrite, &sigc, 1); + if (r == -1) { + sig_errors++; + sig_lasterrno = errno; + } errno = origerrno; } @@ -1655,6 +1663,7 @@ static int qemudOneLoop(struct qemud_server *server, int timeout) { struct pollfd fds[nfds]; int thistimeout = -1; int ret; + sig_atomic_t errors; /* If we have no clients or vms, then timeout after 30 seconds, letting daemon exit */ @@ -1682,6 +1691,16 @@ static int qemudOneLoop(struct qemud_server *server, int timeout) { return -1; } + /* Check for any signal handling errors and log them. */ + errors = sig_errors; + if (errors) { + sig_errors -= errors; + qemudLog (QEMUD_ERR, + "Signal handler reported %d errors: last error: %s", + errors, strerror (sig_lasterrno)); + return -1; + } + if (qemudDispatchPoll(server, fds) < 0) return -1; -- GitLab