From 7361c104a52c7cd044c7c9b3e7ffd18c96de0695 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Thu, 17 Sep 2026 15:48:09 +0200 Subject: [PATCH] Treat closed Windows pipes as EOF when reading --- os/mingw.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/os/mingw.c b/os/mingw.c index 3e4a2b60..376f5588 100644 --- a/os/mingw.c +++ b/os/mingw.c @@ -2200,7 +2200,13 @@ ssize_t windows_read(int fd, void* buffer, size_t size) } if (!ReadFile(h, buffer, size, &count, 0)) { - windows_errno(GetLastError()); + DWORD error = GetLastError(); + + /* A closed Windows pipe has the same read semantics as a POSIX pipe at EOF. */ + if (error == ERROR_BROKEN_PIPE) + return 0; + + windows_errno(error); return -1; }