| 175 | } |
| 176 | |
| 177 | std::istream* Coprocess::stdout_pipe () |
| 178 | { |
| 179 | if (!stdout_pipe_istream) { |
| 180 | SECURITY_ATTRIBUTES sec_attr; |
| 181 | |
| 182 | // Set the bInheritHandle flag so pipe handles are inherited. |
| 183 | sec_attr.nLength = sizeof(SECURITY_ATTRIBUTES); |
| 184 | sec_attr.bInheritHandle = TRUE; |
| 185 | sec_attr.lpSecurityDescriptor = nullptr; |
| 186 | |
| 187 | // Create a pipe for the child process's STDOUT. |
| 188 | if (!CreatePipe(&stdout_pipe_reader, &stdout_pipe_writer, &sec_attr, 0)) { |
| 189 | throw System_error("CreatePipe", "", GetLastError()); |
| 190 | } |
| 191 | |
| 192 | // Ensure the read handle to the pipe for STDOUT is not inherited. |
| 193 | if (!SetHandleInformation(stdout_pipe_reader, HANDLE_FLAG_INHERIT, 0)) { |
| 194 | throw System_error("SetHandleInformation", "", GetLastError()); |
| 195 | } |
| 196 | |
| 197 | stdout_pipe_istream = new ifhstream(this, read_stdout); |
| 198 | } |
| 199 | return stdout_pipe_istream; |
| 200 | } |
| 201 | |
| 202 | void Coprocess::close_stdout () |
| 203 | { |
nothing calls this directly
no test coverage detected