summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bfdd9ff)
raw | patch | inline | side by side (parent: bfdd9ff)
author | Johannes Sixt <johannes.sixt@telecom.at> | |
Fri, 17 Aug 2007 16:40:36 +0000 (18:40 +0200) | ||
committer | Johannes Sixt <johannes.sixt@telecom.at> | |
Thu, 26 Jun 2008 06:47:15 +0000 (08:47 +0200) |
On Windows, write() is implemented using WriteFile(). After the reader
closed its end of the pipe, the first WriteFile() returns
ERROR_BROKEN_PIPE (which translates to EPIPE), subsequent WriteFile()s
return ERROR_NO_DATA, which is translated to EINVAL.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
closed its end of the pipe, the first WriteFile() returns
ERROR_BROKEN_PIPE (which translates to EPIPE), subsequent WriteFile()s
return ERROR_NO_DATA, which is translated to EINVAL.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
write_or_die.c | patch | blob | history |
diff --git a/write_or_die.c b/write_or_die.c
index 630be4cb9414b1686a5ad86a4d5166f2828096f1..e4c8e225fd232dfd642aa13d7ae5b64b9827c915 100644 (file)
--- a/write_or_die.c
+++ b/write_or_die.c
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));
}