MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / internalLaunch

Method internalLaunch

Libraries/Process/Process.cpp:24–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22//-------------------------------------------------------------------------------------------------------
23
24SC::Result SC::ProcessChain::internalLaunch(const Process::StdOut& stdOut, const Process::StdIn& stdIn,
25 const Process::StdErr& stdErr)
26{
27 if (processes.isEmpty())
28 {
29 return Result::Error("ProcessChain::launch - No Processes");
30 }
31 for (Process* process = processes.front; process != nullptr; process = process->next)
32 {
33 process->options = options;
34 if (process == processes.front)
35 {
36 if (process == processes.back)
37 {
38 // single item in the list
39 SC_TRY(process->launch(stdOut, stdIn, stdErr));
40 }
41 else
42 {
43 // stdout and stderr are chained from previous process
44 SC_TRY(process->launch(Process::StdOut::AlreadySetup(), stdIn, Process::StdErr::AlreadySetup()));
45 }
46 }
47 else if (process == processes.back)
48 {
49 // Gets stdin from previous process in the chain
50 SC_TRY(process->launch(stdOut, Process::StdIn::AlreadySetup(), stdErr));
51 }
52 else
53 {
54 // Use directly launchImplementation as we've already setup redirection manually
55 SC_TRY(process->launchImplementation());
56 }
57 }
58 return Result(true);
59}
60
61SC::Result SC::ProcessChain::pipe(Process& process, const Span<const StringSpan> cmd)
62{

Callers

nothing calls this directly

Calls 5

AlreadySetupClass · 0.85
ErrorEnum · 0.50
ResultClass · 0.50
isEmptyMethod · 0.45
launchMethod · 0.45

Tested by

no test coverage detected