]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Fix para_next_signal().
authorAndre Noll <maan@systemlinux.org>
Mon, 17 Mar 2008 06:34:29 +0000 (07:34 +0100)
committerAndre Noll <maan@systemlinux.org>
Mon, 17 Mar 2008 06:34:29 +0000 (07:34 +0100)
The function returned zero in case of errors..

signal.c

index 78e788d19021111b2f8ec712eb1ff8f0fd176375..0490a3a1f10a0897c311bc144ba7ce876652fb14 100644 (file)
--- a/signal.c
+++ b/signal.c
@@ -124,25 +124,31 @@ int para_install_sighandler(int sig)
 }
 
 /**
- * return number of next pending signal
+ * Return the number of next pending signal.
  *
  * This should be called if the fd for the signal pipe is ready for reading.
  *
- * \return On success, the number of the received signal is returned. \p
- * -E_SIGNAL_READ is returned if a read error occurred while reading the signal
- * pipe.  If the read was interrupted by another signal the function returns 0.
+ * \return On success, the number of the received signal is returned.  If the
+ * read returned zero or was interrupted by another signal the function returns
+ * 0.  Otherwise, a negative error value is returned.
  */
 int para_next_signal(void)
 {
        int s;
-       ssize_t r;
+       ssize_t r = read(signal_pipe[0], &s, sizeof(s));
 
-       r = read(signal_pipe[0], &s, sizeof(s));
-       if (r == sizeof(s)) {
-               PARA_DEBUG_LOG("next signal: %d\n", s);
-               return s;
+       if (!r) {
+               PARA_CRIT_LOG("read from signal pipe returned zero\n");
+               return 0;
+       }
+       if (r < 0) {
+               if (errno == EAGAIN || errno == EINTR)
+                       return 0;
+               return -ERRNO_TO_PARA_ERROR(errno);
        }
-       return r < 0 && (errno != EAGAIN)? 0 : -E_SIGNAL_READ;
+       assert(r == sizeof(s));
+       PARA_DEBUG_LOG("next signal: %d\n", s);
+       return s;
 }
 
 /**