diff options
author | Azat Khuzhin <a3at.mail@gmail.com> | 2017-03-06 00:05:50 +0300 |
---|---|---|
committer | Azat Khuzhin <a3at.mail@gmail.com> | 2017-03-08 13:31:55 +0300 |
commit | 66a4eb0c3ae3b1f22b084b2d3aeb5c872f37efbd (patch) | |
tree | fcf98c99076366fd494261cc1420bd6417a01298 | |
parent | b2b4b4d74e78a3e4fe7a74224d1e6aada5bde351 (diff) | |
download | libevent-66a4eb0c3ae3b1f22b084b2d3aeb5c872f37efbd.tar.gz |
Check for WNOWAIT in waitpid() in runtime (not in cmake/configure)
Because checking in cmake breaks cross-compiling.
Introduced-in: 43eb56c7c738e3642f0981e3dd6ab9e082eec798.
Fixes: #482
Fixes: #462
Refs: #475
v2: use waitid() with WNOWAIT
v3: use WNOWAIT only if it available in waitpid(), because not all netbsd
supports it
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | cmake/CheckWaitpidSupportWNOWAIT.cmake | 18 | ||||
-rw-r--r-- | configure.ac | 20 | ||||
-rw-r--r-- | event-config.h.cmake | 5 | ||||
-rw-r--r-- | test/regress.c | 8 |
5 files changed, 3 insertions, 50 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 343bf5f7..1eabc243 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -494,8 +494,6 @@ CHECK_TYPE_SIZE("void *" EVENT__SIZEOF_VOID_P) #CHECK_FILE_OFFSET_BITS() #set(EVENT___FILE_OFFSET_BITS _FILE_OFFSET_BITS) -include(CheckWaitpidSupportWNOWAIT) - # Verify kqueue works with pipes. if (EVENT__HAVE_KQUEUE) if (CMAKE_CROSSCOMPILING AND NOT EVENT__FORCE_KQUEUE_CHECK) diff --git a/cmake/CheckWaitpidSupportWNOWAIT.cmake b/cmake/CheckWaitpidSupportWNOWAIT.cmake deleted file mode 100644 index 1a73db37..00000000 --- a/cmake/CheckWaitpidSupportWNOWAIT.cmake +++ /dev/null @@ -1,18 +0,0 @@ -include(CheckCSourceRuns) - -check_c_source_runs( -" -#include <unistd.h> -#include <sys/types.h> -#include <sys/wait.h> -#include <stdlib.h> - -int -main(int argc, char** argv) -{ - pid_t pid; - int status; - if ((pid = fork()) == 0) _exit(0); - _exit(waitpid(pid, &status, WNOWAIT) == -1); -}" -EVENT__HAVE_WAITPID_WITH_WNOWAIT) diff --git a/configure.ac b/configure.ac index 47ba344a..a127bbc9 100644 --- a/configure.ac +++ b/configure.ac @@ -599,26 +599,6 @@ main(int argc, char **argv) fi AM_CONDITIONAL(EPOLL_BACKEND, [test "x$haveepoll" = "xyes"]) -AC_MSG_CHECKING(waitpid support WNOWAIT) -AC_TRY_RUN( -#include <unistd.h> -#include <sys/types.h> -#include <sys/wait.h> -#include <stdlib.h> - -int -main(int argc, char** argv) -{ - pid_t pid; - int status; - if ((pid = fork()) == 0) _exit(0); - _exit(waitpid(pid, &status, WNOWAIT) == -1); -}, [AC_MSG_RESULT(yes) -AC_DEFINE(HAVE_WAITPID_WITH_WNOWAIT, 1, -[Define if waitpid() supports WNOWAIT]) -], AC_MSG_RESULT(no), AC_MSG_RESULT(no)) - - haveeventports=no AC_CHECK_FUNCS(port_create, [haveeventports=yes], ) if test "x$haveeventports" = "xyes" ; then diff --git a/event-config.h.cmake b/event-config.h.cmake index 51ed1a18..65a0f5dd 100644 --- a/event-config.h.cmake +++ b/event-config.h.cmake @@ -526,7 +526,4 @@ #cmakedefine EVENT__NEED_DLLIMPORT 1 -/* Define if waitpid() supports WNOWAIT */ -#cmakedefine EVENT__HAVE_WAITPID_WITH_WNOWAIT 1 - -#endif +#endif /* \EVENT2_EVENT_CONFIG_H_INCLUDED_ */ diff --git a/test/regress.c b/test/regress.c index d8a6b9b8..94fcbec9 100644 --- a/test/regress.c +++ b/test/regress.c @@ -855,11 +855,6 @@ test_fork(void) int status; struct event ev, sig_ev, usr_ev, existing_ev; pid_t pid; - int wait_flags = 0; - -#ifdef EVENT__HAVE_WAITPID_WITH_WNOWAIT - wait_flags |= WNOWAIT; -#endif setup_test("After fork: "); @@ -934,7 +929,8 @@ test_fork(void) } TT_BLATHER(("Before waitpid")); - if (waitpid(pid, &status, wait_flags) == -1) { + if ((waitpid(pid, &status, WNOWAIT) == -1 && errno == EINVAL) && + waitpid(pid, &status, 0) == -1) { perror("waitpid"); exit(1); } |