Execute multiple child processes chaining input / output between them. More...
#include <Process.h>
Public Member Functions | |
Result | pipe (Process &process, const Span< const StringView > cmd) |
Add a process to the chain, with given arguments. More... | |
Result | launch (const Process::StdOut &stdOut=Process::StdOut::Inherit{}, const Process::StdIn &stdIn=Process::StdIn::Inherit{}, const Process::StdErr &stdErr=Process::StdErr::Inherit{}) |
Launch the entire chain of processes. More... | |
Result | waitForExitSync () |
Waits (blocking) for entire process chain to exit. More... | |
Result | exec (const Process::StdOut &stdOut=Process::StdOut::Inherit{}, const Process::StdIn &stdIn=Process::StdIn::Inherit{}, const Process::StdErr &stdErr=Process::StdErr::Inherit{}) |
Launch the entire chain of processes and waits for the results (calling ProcessChain::waitForExitSync) More... | |
Public Attributes | |
Process::Options | options |
Execute multiple child processes chaining input / output between them.
Chains multiple child processes together, so that the output of a process becomes input of another (similar to what happens wit the pipe (|
) operator on Posix shells).
SC::PipeDescriptor from File library is used to chain read / write endpoints of different processes together.
Example: Inherit stdout file descriptor
Example: Read stderr and stdout into a string
Example: Read standard output into a string using a Pipe
|
inline |
Launch the entire chain of processes and waits for the results (calling ProcessChain::waitForExitSync)
Result SC::ProcessChain::launch | ( | const Process::StdOut & | stdOut = Process::StdOut::Inherit{} , |
const Process::StdIn & | stdIn = Process::StdIn::Inherit{} , |
||
const Process::StdErr & | stdErr = Process::StdErr::Inherit{} |
||
) |
Launch the entire chain of processes.
Reading from pipes can be done after launching. You can then call ProcessChain::waitForExitSync to block until the child process is fully finished.
Result SC::ProcessChain::pipe | ( | Process & | process, |
const Span< const StringView > | cmd | ||
) |
Result SC::ProcessChain::waitForExitSync | ( | ) |
Waits (blocking) for entire process chain to exit.
Can be called only after ProcessChain::launch.