Skip to content

Commit 583206e

Browse files
committed
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.
1 parent 1c25e49 commit 583206e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

compat/mingw.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ static inline ssize_t mingw_write(int fd, const void *buf, size_t len)
229229
{
230230
ssize_t result = write(fd, buf, len);
231231

232-
if (result < 0 && errno == EINVAL) {
232+
if (result < 0 && errno == EINVAL && buf) {
233233
/* check if fd is a pipe */
234234
HANDLE h = (HANDLE) _get_osfhandle(fd);
235235
if (GetFileType(h) == FILE_TYPE_PIPE)

0 commit comments

Comments
 (0)