Skip to content

Add clean failure for EVFILT_PROC usage #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,33 @@ AC_SEARCH_LIBS(pthread_create, pthread)
#
# Prefer native kqueue(2); otherwise use libkqueue if present.
#
AC_CHECK_HEADER(sys/event.h, [],
AC_CHECK_HEADER(kqueue/sys/event.h,
[kqueue_include="#include <kqueue/sys/event.h>"
kqueue_lib="-lkqueue"]
)

AC_CHECK_HEADER(sys/event.h,
[kqueue_include="#include <sys/event.h>"],
[PKG_CHECK_MODULES(KQUEUE, libkqueue)]
)

AC_SUBST([LIBS],["${LIBS} $kqueue_lib"])
AC_RUN_IFELSE(
[AC_LANG_PROGRAM([
$kqueue_include
#include <stdlib.h>], [
int kq, i;
struct kevent ke;
kq = kqueue();
if (kq == -1) return(1);
EV_SET(&ke, 1, EVFILT_PROC, EV_ADD, NOTE_EXIT | NOTE_FORK | NOTE_EXEC, 0, NULL);
i = kevent(kq, &ke, 1, NULL, 0, NULL);
if (i == -1) return(1);
return(0);])],
[AC_DEFINE(HAVE_EVFILT_PROC, 1, [Define if EVFILT_PROC available])],
[AC_DEFINE(HAVE_EVFILT_PROC, 0, [Define if EVFILT_PROC available])]
)

AC_CHECK_FUNCS([strlcpy getprogname], [],
[PKG_CHECK_MODULES(BSD_OVERLAY, libbsd-overlay,[
AC_DEFINE(HAVE_STRLCPY, 1, [])
Expand Down
7 changes: 7 additions & 0 deletions src/source.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ dispatch_source_create(dispatch_source_type_t type,
}

switch (type->ke.filter) {
#if !HAVE_EVFILT_PROC
// return null if not supported
case EVFILT_PROC:
return NULL;
break;
#endif

case EVFILT_SIGNAL:
if (handle >= NSIG) {
return NULL;
Expand Down
2 changes: 1 addition & 1 deletion tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ noinst_SCRIPTS=leaks-wrapper.sh

UNPORTED_TESTS= \
dispatch_deadname \
dispatch_proc \
dispatch_vm \
dispatch_vnode \
dispatch_select

PORTED_TESTS_FAILED= \
dispatch_proc \
dispatch_group \
dispatch_priority \
dispatch_priority2 \
Expand Down
8 changes: 6 additions & 2 deletions tests/dispatch_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@ test_proc(pid_t bad_pid)
posix_spawnattr_t attr;
res = posix_spawnattr_init(&attr);
assert(res == 0);
res = posix_spawnattr_setflags(&attr, POSIX_SPAWN_START_SUSPENDED);
assert(res == 0);

#if HAVE_POSIX_SPAWN_START_SUSPENDED
short spawnflags = POSIX_SPAWN_START_SUSPENDED;
res = posix_spawnattr_setflags(&attr, spawnflags);
assert(res == 0);
#endif

char* args[] = {
"/bin/sleep", "2", NULL
Expand Down