12 inline ProcessRunner::Exception::Exception (
const String& failureMessage,
const optional<String>& stderrFragment,
13 const optional<ExitStatusType>& wExitStatus,
const optional<SignalID>& wTermSig)
14 : inherited{mkMsg_ (failureMessage, stderrFragment, wExitStatus, wTermSig)}
15 , fFailureMessage{failureMessage}
16 , fStderrFragment{stderrFragment}
17 , fExitStatus{wExitStatus}
18 , fTermSignal{wTermSig}
27#if qCompilerAndStdLib_DefaultMemberInitializerNeededEnclosingForDefaultFunArg_Buggy
28 inline ProcessRunner::ProcessRunner (
const filesystem::path& executable,
const CommandLine& args)
29 : ProcessRunner{executable, args, Options{}}
32 inline ProcessRunner::ProcessRunner (
const CommandLine& args)
33 : ProcessRunner{args, Options{}}
36 inline ProcessRunner::ProcessRunner (
const String& commandLine)
37 : ProcessRunner{commandLine, Options{}}
41 inline ProcessRunner::ProcessRunner (
const filesystem::path& executable,
const CommandLine& args,
const Options& o)
42 : fExecutable_{executable}
47 inline ProcessRunner::ProcessRunner (
const CommandLine& args,
const Options& o)
52 inline ProcessRunner::ProcessRunner (
const filesystem::path& executable,
const CommandLine& args,
const Streams::InputStream::Ptr<byte>& in,
53 const Streams::OutputStream::Ptr<byte>& out,
const Streams::OutputStream::Ptr<byte>& error)
54 : fExecutable_{executable}
61 inline ProcessRunner::ProcessRunner (
const CommandLine& args,
const Streams::InputStream::Ptr<byte>& in,
62 const Streams::OutputStream::Ptr<byte>& out,
const Streams::OutputStream::Ptr<byte>& error)
70 inline CommandLine ProcessRunner::GetCommandLine ()
const
72 Debug::AssertExternallySynchronizedMutex::ReadContext declareContext{fThisAssertExternallySynchronized_};
75 inline void ProcessRunner::SetCommandLine (
const CommandLine& args)
77 Debug::AssertExternallySynchronizedMutex::WriteContext declareContext{fThisAssertExternallySynchronized_};
80 inline optional<filesystem::path> ProcessRunner::GetWorkingDirectory ()
const
82 Debug::AssertExternallySynchronizedMutex::ReadContext declareContext{fThisAssertExternallySynchronized_};
83 return fOptions_.fWorkingDirectory;
85 inline void ProcessRunner::SetWorkingDirectory (
const optional<filesystem::path>& d)
87 Debug::AssertExternallySynchronizedMutex::WriteContext declareContext{fThisAssertExternallySynchronized_};
88 fOptions_.fWorkingDirectory = d;
90 inline auto ProcessRunner::GetOptions () const -> Options
92 Debug::AssertExternallySynchronizedMutex::ReadContext declareContext{fThisAssertExternallySynchronized_};
95 inline void ProcessRunner::SetOptions (
const Options& o)
97 Debug::AssertExternallySynchronizedMutex::WriteContext declareContext{fThisAssertExternallySynchronized_};
136 inline optional<ProcessRunner::ProcessResultType> ProcessRunner::BackgroundProcess::GetProcessResult ()
const
139 return fRep_->fResult;
141 inline optional<pid_t> ProcessRunner::BackgroundProcess::GetChildProcessID ()
const
149 [[deprecated (
"Since Stroika v3.0d13 - use ProcessRunner{Options{.fDetached=true}")]]
inline pid_t
157 [[deprecated (
"Since Stroika v3.0d13 - use ProcessRunner{Options{.fDetached=true}")]]
inline pid_t DetachedProcessRunner (
const String& commandLine)
160 ProcessRunner pr{CommandLine{commandLine}, ProcessRunner::Options{.fDetached =
true}};
161 ProcessRunner::BackgroundProcess bp = pr.RunInBackground ();
162 bp.WaitForStarted ();
163 return Memory::ValueOf (bp.GetChildProcessID ());
A generalization of a vector: a container whose elements are keyed by the natural numbers.
shared_lock< const AssertExternallySynchronizedMutex > ReadContext
Instantiate AssertExternallySynchronizedMutex::ReadContext to designate an area of code where protect...
unique_lock< AssertExternallySynchronizedMutex > WriteContext
Instantiate AssertExternallySynchronizedMutex::WriteContext to designate an area of code where protec...
nonvirtual void WaitForStarted(Time::DurationSeconds timeout=Time::kInfinity) const
wait until GetChildProcessID () returns a valid answer, or until the process failed to start (in whic...
optional< pid_t > GetChildProcessID() const
maybe missing if process not yet (or ever successfully) launched. Child process may have already exit...
Run the given command, and optionally support stdin/stdout/stderr as streams (either sync with Run,...
OutputStream<>::Ptr is Smart pointer to a stream-based sink of data.
int pid_t
TODO - maybe move this to configuraiotn module???
pid_t DetachedProcessRunner(const filesystem::path &executable, const Containers::Sequence< String > &args)
DEPRECATED.