]> git.tue.mpg.de Git - paraslash.git/commitdiff
Check return value of write() in generic_signal_handler().
authorAndre Noll <maan@systemlinux.org>
Fri, 28 Nov 2008 12:04:30 +0000 (13:04 +0100)
committerAndre Noll <maan@systemlinux.org>
Fri, 28 Nov 2008 12:04:30 +0000 (13:04 +0100)
Abort if we could not write the signal number to the pipe (which
should never happen).

signal.c

index f8be2f4612002214f669fa74ce92390866b0dc90..9168e918205a5f6733761db31ea7fc6573b2bbae 100644 (file)
--- 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);
 }
 
 /**