diff options
author | Tom Smeding <tom.smeding@gmail.com> | 2018-07-21 22:03:31 +0200 |
---|---|---|
committer | Tom Smeding <tom.smeding@gmail.com> | 2018-07-21 22:03:31 +0200 |
commit | f0b6d1b9c46578183b427bcec4bbe99ab10c7b97 (patch) | |
tree | 111df40d4485f7dc7a66d0d463688021474512c1 /competition/process.h | |
parent | 53291958e0cda68ed762c0dfb36c0602f876c06d (diff) |
competition: reorganisation and multithread
Diffstat (limited to 'competition/process.h')
-rw-r--r-- | competition/process.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/competition/process.h b/competition/process.h new file mode 100644 index 0000000..ddd80b9 --- /dev/null +++ b/competition/process.h @@ -0,0 +1,32 @@ +#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); + + void redirectStderr(const string_view fname); + + void run(); + void wait(); + void stop(); + void unStop(); + void terminate(); + + bool writeLine(const string_view line); + optional<string> readLine(); +}; |