System: fix Windows process pipe busy loop

A synchronous zero-byte pipe read was stored as ready data, leaving
communicate_blocking with nothing to wait on and no progress (a spin).
Treat a zero-byte read as EOF in both the issue and completion paths.
Make the stdout/stderr independence test use cmd.exe syntax on Windows.

Wine 11, x86_64-w64-mingw32 GCC 16.2: full VoidTests.exe suite passes
(1337 tests, 1323 passed, 14 skipped, 0 failed).

Refs #65
This commit is contained in:
faumaray committed 2026-12-05 20:33:16 +03:00
1 parent 3939b05396
commit 796609787e
2 files changed
+19 -2

No files matched your search

+15 -2
View File
@@ -627,7 +627,16 @@ namespace
&got, &got,
&stream.ov) != 0) &stream.ov) != 0)
{ {
stream.read_ready = got; // A zero-byte success is EOF; storing it as "ready" data would
// leave the caller with nothing to wait on (busy loop).
if (got == 0)
{
stream.eof = true;
}
else
{
stream.read_ready = got;
}
return; return;
} }
const DWORD error = ::GetLastError(); const DWORD error = ::GetLastError();
@@ -688,8 +697,12 @@ namespace
got = stream.read_ready; got = stream.read_ready;
stream.read_ready = 0; stream.read_ready = 0;
} }
if (got == 0)
{
return IoStatus::eof;
}
bytes = got; bytes = got;
return got > 0 ? IoStatus::data : IoStatus::none; return IoStatus::data;
} }
void issue_write(WinStream& stream, void issue_write(WinStream& stream,
+4
View File
@@ -94,8 +94,12 @@ Void::Testing::Test run_missing_executable_returns_code_127()
Void::Testing::Test run_stdout_and_stderr_independent() Void::Testing::Test run_stdout_and_stderr_independent()
{ {
#ifdef _WIN32
auto r = Void::Process::shell("echo to_stdout & echo to_stderr 1>&2");
#else
auto r = Void::Process::shell( auto r = Void::Process::shell(
"echo to_stdout; echo to_stderr >&2"); "echo to_stdout; echo to_stderr >&2");
#endif
Void::Testing::expect(r.has_value()); Void::Testing::expect(r.has_value());
Void::Testing::expect(r->out.find("to_stdout") != std::string::npos); Void::Testing::expect(r->out.find("to_stdout") != std::string::npos);
Void::Testing::expect(r->err.find("to_stderr") != std::string::npos); Void::Testing::expect(r->err.find("to_stderr") != std::string::npos);