Special-case BROKEN_PIPE and NO_DATA errors when calling WriteFile

This commit is contained in:
Sapphire committed 2026-05-27 03:07:39 -05:00
1 parent d1a39dba05
commit f2770ca6a5
1 file changed
+5 -1
@@ -197,7 +197,11 @@ public class WindowsNamedPipe implements AutoCloseable {
.WriteFile(handle, buffer, len, null, overlappedWrite);
int err = k32.GetLastError();
if (!immediate && err != WinError.ERROR_IO_PENDING) {
setError("WriteFile failed: " + err);
if (err == WinError.ERROR_BROKEN_PIPE || err == WinError.ERROR_NO_DATA) {
setError("Pipe closed");
} else {
setError("WriteFile failed: " + err);
}
return false;
}