- Server(string &&binary_, str_args_t &&str_args_ = {}, dyn_args_t &&dyn_args_ = {})
- : binary{binary_}
- , str_args{str_args_}
- , dyn_args{dyn_args_}
- {}
-
- Server(string &&binary_, dyn_args_t &&dyn_args_)
- : binary{binary_}
- , str_args{}
- , dyn_args{dyn_args_}
- {}
-
- ~Server() {
- stop();
- wait();
- }
-
- Server &operator = (const Server &s) = default;
- Server(const Server &s) = default;
-
- Server &operator = (Server &&s) = default;
- Server(Server &&s) = default;
-
- pid_t getPid() const {
- return pid;
- }
-
- const string &getBinary() const {
- return binary;
- }
-
- const socket_or_port_t &getSocketOrPort() const {
- return socket_or_port;
- }
-
- optional<pid_t> start();
+ Server(string binary_ = "false", argv_t args_ = {});
+
+ ~Server();
+
+ Server(const Server &s);
+ Server &operator = (const Server &s);
+
+ Server(Server &&s) {
+ *this = move(s);
+ };
+ Server &operator = (Server &&s) {
+ binary = exchange(s.binary, "false");
+ args = exchange(s.args, {});
+ pid = exchange(s.pid, 0);
+ pipe = exchange(s.pipe, -1);
+ status = exchange(s.status, 0);
+ signalled = exchange(s.signalled, {});
+ socket_or_port = exchange(s.socket_or_port, {});
+ output = exchange(s.output, {});
+ return *this;
+ };
+
+ pid_t getPid() const;
+ int getPipe() const;
+ const string &getBinary() const;
+ const argv_t &getArgs() const;
+ const socket_or_port_t &getSocketOrPort() const;
+
+ struct ChildProc {
+ pid_t pid;
+ int pipe;
+ ChildProc(pid_t pid_, int pipe_)
+ : pid{pid_}
+ , pipe{pipe_}
+ {
+ }
+ };
+ optional<ChildProc> start();