diff options
author | Tom Smeding <tom.smeding@gmail.com> | 2018-08-20 21:53:38 +0200 |
---|---|---|
committer | Tom Smeding <tom.smeding@gmail.com> | 2018-08-20 21:53:38 +0200 |
commit | 1c42efb1b116287949e59370198cad2df465835d (patch) | |
tree | 6c191f0a629b23566763827e73071c523f0d3e2b /process.h |
Initial
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(); +}; |