From 646e481578d6e170835097666ae98f8daaff341e Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Fri, 28 Nov 2008 13:04:30 +0100 Subject: [PATCH] Check return value of write() in generic_signal_handler(). Abort if we could not write the signal number to the pipe (which should never happen). --- signal.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/signal.c b/signal.c index f8be2f46..9168e918 100644 --- a/signal.c +++ b/signal.c @@ -57,8 +57,15 @@ err_out: */ static void generic_signal_handler(int s) { - write(signal_pipe[1], &s, sizeof(int)); - //fprintf(stderr, "got sig %i, write returned %d\n", s, ret); + ssize_t ret = write(signal_pipe[1], &s, sizeof(int)); + + if (ret == sizeof(int)) + return; + if (ret < 0) + PARA_EMERG_LOG("%s\n", strerror(errno)); + else + PARA_EMERG_LOG("short write to signal pipe\n"); + exit(EXIT_FAILURE); } /** -- 2.39.5