X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=testing%2Flib%2FForkAndExec.hpp;h=ad7b415150c38ec04b911c749263ec21cc7be194;hb=b5ed9c3cab58f1a8e519d5551951ab8c25fc3b84;hp=ff70abb98f20e40825b37496681d85ad08529f7b;hpb=b64a8e5e114fe91f894641c3981518ea8bc79113;p=awesomized%2Flibmemcached diff --git a/testing/lib/ForkAndExec.hpp b/testing/lib/ForkAndExec.hpp index ff70abb9..ad7b4151 100644 --- a/testing/lib/ForkAndExec.hpp +++ b/testing/lib/ForkAndExec.hpp @@ -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 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(); };