| 59 | } |
| 60 | |
| 61 | SC::Result SC::ProcessChain::pipe(Process& process, const Span<const StringSpan> cmd) |
| 62 | { |
| 63 | // TODO: Expose options to decide if to pipe also stderr |
| 64 | SC_TRY_MSG(process.parent == nullptr, "Process::pipe - already in use"); |
| 65 | |
| 66 | if (not processes.isEmpty()) |
| 67 | { |
| 68 | PipeDescriptor chainPipe; |
| 69 | PipeOptions chainOptions; |
| 70 | chainOptions.writeInheritable = true; |
| 71 | chainOptions.readInheritable = true; |
| 72 | SC_TRY(chainPipe.createPipe(chainOptions)); |
| 73 | SC_TRY(processes.back->stdOutFd.assign(move(chainPipe.writePipe))); |
| 74 | SC_TRY(process.stdInFd.assign(move(chainPipe.readPipe))); |
| 75 | } |
| 76 | SC_TRY(process.formatArguments(Span<const StringSpan>(cmd))); |
| 77 | process.parent = this; |
| 78 | processes.queueBack(process); |
| 79 | return Result(true); |
| 80 | } |
| 81 | |
| 82 | SC::Result SC::ProcessChain::waitForExitSync() |
| 83 | { |