testing: flush tests
[awesomized/libmemcached] / testing / lib / ForkAndExec.hpp
index ff70abb98f20e40825b37496681d85ad08529f7b..ad7b415150c38ec04b911c749263ec21cc7be194 100644 (file)
@@ -4,7 +4,7 @@
 
 class ForkAndExec {
 public:
-  enum { READ, WRITE } pipe;
+  enum mode { READ, WRITE };
 
   ForkAndExec(const char *binary, char **argv);
   ~ForkAndExec();
@@ -14,10 +14,17 @@ public:
   ForkAndExec(ForkAndExec &&) = default;
   ForkAndExec &operator = (ForkAndExec &&) = default;
 
-  optional<pid_t> operator () ();
+  [[nodiscard]]
+  int createPipe();
+  pid_t operator () ();
 
 private:
   int ready[2], pipes[2];
   const char *binary;
   char **argv;
+
+  bool prepareExecReadyPipe();
+  void prepareOutputPipe();
+  void closePipe(int &fd);
+  void pollExecReadyPipe();
 };