| 250 | } |
| 251 | |
| 252 | size_t Coprocess::read_stdout (void* handle, void* buf, size_t count) |
| 253 | { |
| 254 | // Note that ReadFile on a pipe may return with bytes_read==0 if the other |
| 255 | // end of the pipe writes zero bytes, so retry when this happens. |
| 256 | // When the other end of the pipe actually closes, ReadFile |
| 257 | // fails with ERROR_BROKEN_PIPE. |
| 258 | DWORD bytes_read; |
| 259 | do { |
| 260 | if (!ReadFile(static_cast<Coprocess*>(handle)->stdout_pipe_reader, buf, count, &bytes_read, nullptr)) { |
| 261 | const DWORD read_error = GetLastError(); |
| 262 | if (read_error != ERROR_BROKEN_PIPE) { |
| 263 | throw System_error("ReadFile", "", read_error); |
| 264 | } |
| 265 | return 0; |
| 266 | } |
| 267 | } while (bytes_read == 0); |
| 268 | return bytes_read; |
| 269 | } |
nothing calls this directly
no test coverage detected