summaryrefslogtreecommitdiff
path: root/competition/process.h
diff options
context:
space:
mode:
Diffstat (limited to 'competition/process.h')
-rw-r--r--competition/process.h32
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();
+};