提交 b2f5e268 编写于 作者: J Johannes Sixt

Windows: Work around an oddity when a pipe with no reader is written to.

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: NJohannes Sixt <johannes.sixt@telecom.at>
上级 bfdd9ffd
......@@ -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));
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册