cvsserver: Add support for packed refs
[gitweb.git] / write_or_die.c
index 630be4cb9414b1686a5ad86a4d5166f2828096f1..e4c8e225fd232dfd642aa13d7ae5b64b9827c915 100644 (file)
@@ -34,7 +34,12 @@ void maybe_flush_or_die(FILE *f, const char *desc)
                        return;
        }
        if (fflush(f)) {
-               if (errno == EPIPE)
+               /*
+                * On Windows, EPIPE is returned only by the first write()
+                * after the reading end has closed its handle; subsequent
+                * write()s return EINVAL.
+                */
+               if (errno == EPIPE || errno == EINVAL)
                        exit(0);
                die("write failure on %s: %s", desc, strerror(errno));
        }