From 583206e958d10a1269431981dfc823c0aa46c78a Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sat, 12 Dec 2015 14:37:58 +0100 Subject: [PATCH] squash! mingw: emulate write(2) that fails with a SIGPIPE We fail with EPIPE, not SIGPIPE... Also, replace paragraph about EINVAL on Windows by: According to the documentation, there are two cases in which write() triggers EINVAL: the buffer is NULL, or the length is odd but the mode is 16-bit Unicode (the broken pipe is not mentioned as possible cause). Git never sets the file mode to anything but binary, therefore we know that errno should actually be EPIPE if it is EINVAL and the buffer is not NULL. And append: This works around t5571.11 failing with v2.6.4. --- compat/mingw.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compat/mingw.h b/compat/mingw.h index b4eaf85d41..820fe68de9 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -229,7 +229,7 @@ static inline ssize_t mingw_write(int fd, const void *buf, size_t len) { ssize_t result = write(fd, buf, len); - if (result < 0 && errno == EINVAL) { + if (result < 0 && errno == EINVAL && buf) { /* check if fd is a pipe */ HANDLE h = (HANDLE) _get_osfhandle(fd); if (GetFileType(h) == FILE_TYPE_PIPE)