summaryrefslogtreecommitdiff
path: root/write_or_die.c
diff options
context:
space:
mode:
Diffstat (limited to 'write_or_die.c')
-rw-r--r--write_or_die.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/write_or_die.c b/write_or_die.c
index 630be4c..e4c8e22 100644
--- a/write_or_die.c
+++ b/write_or_die.c
@@ -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));
}