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.
This commit is contained in:
Johannes Schindelin
2015-12-12 14:37:58 +01:00
parent 1c25e495c1
commit 583206e958

View File

@@ -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)