X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=test%2Flib%2FServer.cpp;h=cf520094029949cb94b0ac7d9d61087858370f04;hb=06ac8230e45d1317aaa62e5fa2e711c6a1269495;hp=2744f3e1b9c1876b895cb056d6905518cfb534c4;hpb=7e2b466107a65e22f1cc258ca8643922dbb60352;p=awesomized%2Flibmemcached diff --git a/test/lib/Server.cpp b/test/lib/Server.cpp index 2744f3e1..cf520094 100644 --- a/test/lib/Server.cpp +++ b/test/lib/Server.cpp @@ -3,7 +3,9 @@ #include "ForkAndExec.hpp" #include -#include +#if HAVE_UNISTD_H +# include +#endif Server::Server(string binary_, Server::argv_t args_) : binary{move(binary_)} @@ -117,7 +119,7 @@ optional Server::start() { return ChildProc{pid, pipe}; } -bool Server::isListening() { +bool Server::isListening() const { MemcachedPtr memc; if (holds_alternative(socket_or_port)) { @@ -149,11 +151,16 @@ bool Server::isListening() { } bool Server::ensureListening() { + if (!start()) { + return false; + } return Retry{[this] { again: start(); if (!isListening()) { - if (tryWait()){ + auto old = pid; + if (tryWait()) { + cerr << "Collected zombie " << *this << "(old pid=" << old << ")\n"; goto again; } } @@ -186,7 +193,8 @@ bool Server::check() { bool Server::wait(int flags) { if (pid && pid == waitpid(pid, &status, flags)) { - if (drain().length() && output != "Signal handled: Terminated.\n") { + if (drain().length() && + output.rfind("Signal handled: Terminated", 0) != 0) { cerr << "Output of " << *this << ":\n"; istringstream iss{output};