diff options
Diffstat (limited to 'process.h')
-rw-r--r-- | process.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/process.h b/process.h new file mode 100644 index 0000000..900a0b6 --- /dev/null +++ b/process.h @@ -0,0 +1,36 @@ +#pragma once + +#include <string> +#include <optional> +#include <string_view> +#include <unistd.h> + +using namespace std; + + +class Process { + string execname; + optional<string> stderrRedirect; + pid_t pid = -1; + int infd = -1, outfd = -1; + + string readBuf; + +public: + Process(const string_view execname); + Process(const Process&) = delete; + Process(Process&&) = default; + + void redirectStderr(const string_view fname); + + void run(); + void wait(); + void stop(); + void unStop(); + void terminate(); + + pid_t getPid() const; + + bool writeLine(const string_view line); + optional<string> readLine(); +}; |