From 25c4609a8973f6d14bcba4546ecb8137a29be823 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Wed, 4 Nov 2020 15:21:17 +0100 Subject: [PATCH] check for waitid and NOWAIT --- test/CMakeLists.txt | 4 ++++ test/conf.h.in | 1 + test/lib/Cluster.cpp | 4 ++++ 3 files changed, 9 insertions(+) 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 } } -- 2.30.2