From 1c42efb1b116287949e59370198cad2df465835d Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Mon, 20 Aug 2018 21:53:38 +0200 Subject: Initial --- process.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 process.h (limited to 'process.h') 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 +#include +#include +#include + +using namespace std; + + +class Process { + string execname; + optional 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 readLine(); +}; -- cgit v1.2.3-54-g00ecf