From: Andre Noll Date: Fri, 28 Nov 2008 12:04:30 +0000 (+0100) Subject: Check return value of write() in generic_signal_handler(). X-Git-Tag: v0.3.3~13^2~2 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=646e481578d6e170835097666ae98f8daaff341e;hp=0c4e55bbaa21f24f66e57a555341924840850c71 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). --- 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); } /**