Skip to content

Commit

Permalink
Check for WNOWAIT in waitpid() in runtime (not in cmake/configure)
Browse files Browse the repository at this point in the history
Because checking in cmake breaks cross-compiling.

Introduced-in: 43eb56c.
Fixes: libevent#482
Fixes: libevent#462
Refs: libevent#475

v2: use waitid() with WNOWAIT
v3: use WNOWAIT only if it available in waitpid(), because not all netbsd
    supports it
  • Loading branch information
azat authored and peterbell10 committed Jan 21, 2018
1 parent b1a208e commit 5743b19
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 50 deletions.
2 changes: 0 additions & 2 deletions CMakeLists.txt
Expand Up @@ -492,8 +492,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)
Expand Down
18 changes: 0 additions & 18 deletions cmake/CheckWaitpidSupportWNOWAIT.cmake

This file was deleted.

20 changes: 0 additions & 20 deletions configure.ac
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions event-config.h.cmake
Expand Up @@ -526,7 +526,4 @@
/* Define to 1 if you have ERR_remove_thread_stat(). */
#cmakedefine EVENT__HAVE_ERR_REMOVE_THREAD_STATE

/* Define if waitpid() supports WNOWAIT */
#cmakedefine EVENT__HAVE_WAITPID_WITH_WNOWAIT

#endif
#endif /* \EVENT2_EVENT_CONFIG_H_INCLUDED_ */
8 changes: 2 additions & 6 deletions test/regress.c
Expand Up @@ -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: ");

Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 5743b19

Please sign in to comment.