| 128 | SC::Process::Options::Options() |
| 129 | { |
| 130 | windowsHide = Process::isWindowsConsoleSubsystem(); |
| 131 | windowsCreateNewProcessGroup = false; |
| 132 | } |
| 133 | |
| 134 | SC::Result SC::Process::launch(const StdOut& stdOutput, const StdIn& stdInput, const StdErr& stdError) |
| 135 | { |
| 136 | auto setupInput = [](const StdIn& inputObject, PipeDescriptor& pipe, FileDescriptor& fileDescriptor) |
| 137 | { |
| 138 | switch (inputObject.operation) |
| 139 | { |
| 140 | case StdStream::Operation::AlreadySetup: break; |
| 141 | case StdStream::Operation::Inherit: break; |
| 142 | case StdStream::Operation::Ignore: break; |
| 143 | case StdStream::Operation::FileDescriptor: { |
| 144 | SC_TRY_MSG(fileDescriptor.assign(inputObject.fileDescriptor), "Input file is not valid"); |
| 145 | } |
| 146 | break; |
| 147 | case StdStream::Operation::ExternalPipe: { |
| 148 | SC_TRY_MSG(fileDescriptor.assign(move(inputObject.pipeDescriptor->readPipe)), |
| 149 | "Input pipe is not valid (forgot createPipe?)"); |
| 150 | } |
| 151 | break; |
| 152 | case StdStream::Operation::GrowableBuffer: |
| 153 | case StdStream::Operation::ReadableSpan: { |
| 154 | PipeOptions pipeReadOptions; |
| 155 | pipeReadOptions.readInheritable = true; |
| 156 | pipeReadOptions.writeInheritable = false; |
| 157 | SC_TRY(pipe.createPipe(pipeReadOptions)); |
| 158 | SC_TRY(fileDescriptor.assign(move(pipe.readPipe))); |
| 159 | } |
| 160 | break; |
| 161 | case StdStream::Operation::WritableSpan: { |
| 162 | return Result(false); |
| 163 | } |
| 164 | } |
| 165 | return Result(true); |
| 166 | }; |
| 167 | |
| 168 | auto setupOutput = [](const StdOut& outputObject, PipeDescriptor& pipe, FileDescriptor& fileDescriptor) |
| 169 | { |
| 170 | switch (outputObject.operation) |
| 171 | { |
| 172 | case StdStream::Operation::AlreadySetup: break; |
| 173 | case StdStream::Operation::Inherit: break; |
| 174 | case StdStream::Operation::Ignore: { |
| 175 | SC_TRY(fileDescriptor.openForWriteToDevNull()); |
| 176 | break; |
| 177 | } |
| 178 | case StdStream::Operation::FileDescriptor: { |
| 179 | SC_TRY_MSG(fileDescriptor.assign(outputObject.fileDescriptor), "Output file is not valid"); |
| 180 | } |
| 181 | break; |
| 182 | case StdStream::Operation::ExternalPipe: { |
| 183 | SC_TRY_MSG(fileDescriptor.assign(move(outputObject.pipeDescriptor->writePipe)), |
| 184 | "Output pipe is not valid (forgot createPipe?)"); |
| 185 | } |
| 186 | break; |
| 187 | case StdStream::Operation::GrowableBuffer: |
no test coverage detected