13#include "DebugServer2/Types.h"
33 typedef std::function<void(
void *buf,
size_t size)> RedirectDelegate;
38 RedirectDelegate delegate;
46 std::string _executablePath;
47 StringCollection _arguments;
48 EnvironmentBlock _environment;
49 std::string _workingDirectory;
50 std::thread _delegateThread;
52 std::string _outputBuffer;
63 bool setExecutable(std::string
const &path);
64 bool setShellCommand(std::string
const &command);
65 bool setWorkingDirectory(std::string
const &path);
68 bool setArguments(StringCollection
const &args);
70 template <
typename... Args>
inline bool setArguments(Args
const &... args) {
71 std::string args_[] = {args...};
72 return setArguments(StringCollection(&args_[0], &args_[
sizeof...(Args)]));
76 bool setEnvironment(EnvironmentBlock
const &env);
77 bool addEnvironment(std::string
const &key, std::string
const &val);
80 bool redirectInputToConsole();
81 bool redirectOutputToConsole();
82 bool redirectErrorToConsole();
85 bool redirectInputToNull();
86 bool redirectOutputToNull();
87 bool redirectErrorToNull();
90 bool redirectInputToFile(std::string
const &path);
91 bool redirectOutputToFile(std::string
const &path);
92 bool redirectErrorToFile(std::string
const &path);
95 bool redirectOutputToBuffer();
96 bool redirectErrorToBuffer();
99 bool redirectInputToTerminal();
102 bool redirectOutputToDelegate(RedirectDelegate delegate);
103 bool redirectErrorToDelegate(RedirectDelegate delegate);
106 ErrorCode run(std::function<
bool()> preExecAction = []() {
return true; });
108 bool isRunning()
const;
112 inline ProcessId pid()
const {
return _pid; }
113 inline int exitStatus()
const {
return _exitStatus; }
114 inline int signalCode()
const {
return _signalCode; }
115 inline std::string
const &executable()
const {
return _executablePath; }
116 inline StringCollection
const &arguments()
const {
return _arguments; }
117 inline EnvironmentBlock
const &environment()
const {
return _environment; }
120 ErrorCode input(ByteVector
const &buf);
121 inline std::string
const &output()
const {
return _outputBuffer; }
124 void redirectionThread();
Definition ProcessSpawner.h:20
Definition ProcessSpawner.h:36