| 136 | } |
| 137 | |
| 138 | std::ostream* Coprocess::stdin_pipe () |
| 139 | { |
| 140 | if (!stdin_pipe_ostream) { |
| 141 | SECURITY_ATTRIBUTES sec_attr; |
| 142 | |
| 143 | // Set the bInheritHandle flag so pipe handles are inherited. |
| 144 | sec_attr.nLength = sizeof(SECURITY_ATTRIBUTES); |
| 145 | sec_attr.bInheritHandle = TRUE; |
| 146 | sec_attr.lpSecurityDescriptor = nullptr; |
| 147 | |
| 148 | // Create a pipe for the child process's STDIN. |
| 149 | if (!CreatePipe(&stdin_pipe_reader, &stdin_pipe_writer, &sec_attr, 0)) { |
| 150 | throw System_error("CreatePipe", "", GetLastError()); |
| 151 | } |
| 152 | |
| 153 | // Ensure the write handle to the pipe for STDIN is not inherited. |
| 154 | if (!SetHandleInformation(stdin_pipe_writer, HANDLE_FLAG_INHERIT, 0)) { |
| 155 | throw System_error("SetHandleInformation", "", GetLastError()); |
| 156 | } |
| 157 | |
| 158 | stdin_pipe_ostream = new ofhstream(this, write_stdin); |
| 159 | } |
| 160 | return stdin_pipe_ostream; |
| 161 | } |
| 162 | |
| 163 | void Coprocess::close_stdin () |
| 164 | { |
nothing calls this directly
no test coverage detected