diff --git a/compat/mingw.c b/compat/mingw.c index 9152ab9fe70274..8b7b526d9f6fa6 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -948,7 +948,7 @@ ssize_t mingw_write(int fd, const void *buf, size_t len) { ssize_t result = write(fd, buf, len); - if (result < 0 && errno == EINVAL && buf) { + if (result < 0 && (errno == EINVAL || errno == EBADF) && buf) { /* check if fd is a pipe */ HANDLE h = (HANDLE) _get_osfhandle(fd); if (GetFileType(h) == FILE_TYPE_PIPE)