Make daemon-exclude errors more error-like.
[rsync/rsync.git] / clientserver.c
index 8fedbe6..fbd3af6 100644 (file)
@@ -374,7 +374,14 @@ static char *finish_pre_exec(pid_t pid, int write_fd, int read_fd, char *request
 
        /* Read the stdout from the pre-xfer exec program.  This it is only
         * displayed to the user if the script also returns an error status. */
-       for (bp = buf; msglen > 0 && (j = read(read_fd, bp, msglen)) > 0; msglen -= j) {
+       for (bp = buf; msglen > 0; msglen -= j) {
+               if ((j = read(read_fd, bp, msglen)) <= 0) {
+                       if (j == 0)
+                               break;
+                       if (errno == EINTR)
+                               continue;
+                       break; /* Just ignore the read error for now... */
+               }
                bp += j;
                if (j > 1 && bp[-1] == '\n' && bp[-2] == '\r') {
                        bp--;
@@ -389,9 +396,10 @@ static char *finish_pre_exec(pid_t pid, int write_fd, int read_fd, char *request
        if (wait_process(pid, &status, 0) < 0
         || !WIFEXITED(status) || WEXITSTATUS(status) != 0) {
                char *e;
-               if (asprintf(&e, "pre-xfer exec returned failure (%d)%s%s\n%s",
+               if (asprintf(&e, "pre-xfer exec returned failure (%d)%s%s%s\n%s",
                             status, status < 0 ? ": " : "",
-                            status < 0 ? strerror(errno) : "", buf) < 0)
+                            status < 0 ? strerror(errno) : "",
+                            *buf ? ":" : "", buf) < 0)
                        return "out_of_memory in finish_pre_exec\n";
                return e;
        }