From: Michael Wallner Date: Wed, 4 Nov 2020 14:21:17 +0000 (+0100) Subject: check for waitid and NOWAIT X-Git-Tag: 1.1.0-beta1~125 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=25c4609a8973f6d14bcba4546ecb8137a29be823;p=m6w6%2Flibmemcached check for waitid and NOWAIT --- diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 449223f0..4b108466 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -14,6 +14,10 @@ endif() check_decl(pipe2 unistd.h) check_decl(SOCK_NONBLOCK sys/socket.h) check_decl(SOCK_CLOEXEC sys/socket.h) +check_decl(waitid sys/wait.h) +if(HAVE_WAITID) + check_compiles(HAVE_WAITID_NOWAIT "siginfo_t s; waitid(P_ALL, 0, &s, WNOWAIT|WEXITED);" sys/types.h sys/wait.h) +endif() file(GLOB_RECURSE TESTING_SRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp) set(TESTING_ROOT ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/test/conf.h.in b/test/conf.h.in index 284d9653..2d2d0360 100644 --- a/test/conf.h.in +++ b/test/conf.h.in @@ -21,6 +21,7 @@ #cmakedefine HAVE_SOCK_CLOEXEC 1 #cmakedefine HAVE_EXECUTION 1 #cmakedefine HAVE_TBB 1 +#cmakedefine HAVE_WAITID_NOWAIT 1 #cmakedefine TESTING_ROOT "@TESTING_ROOT@" #cmakedefine MEMCACHED_BINARY getenv_else("MEMCACHED_BINARY", "@MEMCACHED_BINARY@") diff --git a/test/lib/Cluster.cpp b/test/lib/Cluster.cpp index 37ec184e..de05a797 100644 --- a/test/lib/Cluster.cpp +++ b/test/lib/Cluster.cpp @@ -98,6 +98,7 @@ void Cluster::wait() { siginfo_t inf; while (!isStopped()) { +#if HAVE_WAITID_NOWAIT if (waitid(P_ALL, 0, &inf, WEXITED | WNOWAIT)) { perror("Cluster::wait waitid()"); return; @@ -107,6 +108,9 @@ void Cluster::wait() { if (server != pids.end()) { server->second->wait(); } +#else + this_thread::sleep_for(100ms); +#endif } }