diff options
author | jonathan <jonathan@FreeBSD.org> | 2011-07-07 18:07:03 +0000 |
---|---|---|
committer | jonathan <jonathan@FreeBSD.org> | 2011-07-07 18:07:03 +0000 |
commit | f1301f9a76f64361bb7eefc6d0e275bedb2b2b4c (patch) | |
tree | f40dbd027ae029159206ef752c984c56ebb54415 /tools/regression/kqueue/proc.c | |
parent | b468f23f53f72f2ea48e9e486838dcaecafa6c75 (diff) | |
download | FreeBSD-src-f1301f9a76f64361bb7eefc6d0e275bedb2b2b4c.zip FreeBSD-src-f1301f9a76f64361bb7eefc6d0e275bedb2b2b4c.tar.gz |
Ensure that kqueue is not inherited across fork().
Modify the existing unit test (from libkqueue) which already exercises process events via
fork() and kill(). Now, the child process simply checks that the 'kqfd' descriptor is invalid.
Some minor modifications were required to make err() work correctly. It seems that this test
was imported using the output of a configure script, but config.h was not included in key
places, nor was its syntax correct (need '#define HAVE_FOO 1' rather than '#define HAVE_FOO').
Finally, change main() to run the "proc" suite by default, but widened the '#if TODO' in
proc.c to include the non-functioning test event_trigger().
Approved by: mentor (rwatson), re (Capsicum blanket)
Sponsored by: Google Inc
Diffstat (limited to 'tools/regression/kqueue/proc.c')
-rw-r--r-- | tools/regression/kqueue/proc.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/tools/regression/kqueue/proc.c b/tools/regression/kqueue/proc.c index d4e863e..2835c64 100644 --- a/tools/regression/kqueue/proc.c +++ b/tools/regression/kqueue/proc.c @@ -16,6 +16,11 @@ * $FreeBSD$ */ +#include <sys/stat.h> + +#include <err.h> + +#include "config.h" #include "common.h" static int sigusr1_caught = 0; @@ -37,6 +42,11 @@ add_and_delete(void) /* Create a child that waits to be killed and then exits */ pid = fork(); if (pid == 0) { + struct stat s; + if ((fstat(kqfd, &s) != -1) || (errno != EBADF)) + err(1, "%s:%d - %s: fstat(kqfd) in child did not return EBADF", + __FILE__, __LINE__, __func__); + pause(); exit(2); } @@ -52,6 +62,7 @@ add_and_delete(void) test_begin("kevent(EVFILT_PROC, EV_DELETE)"); + sleep(1); test_no_kevents(); kevent_add(kqfd, &kev, pid, EVFILT_PROC, EV_DELETE, 0, 0, NULL); if (kill(pid, SIGKILL) < 0) @@ -63,6 +74,7 @@ add_and_delete(void) } +#ifdef TODO static void event_trigger(void) { @@ -93,7 +105,6 @@ event_trigger(void) success(); } -#ifdef TODO void test_kevent_signal_disable(void) { @@ -225,7 +236,10 @@ test_evfilt_proc() signal(SIGUSR1, sig_handler); add_and_delete(); + +#if TODO event_trigger(); +#endif signal(SIGUSR1, SIG_DFL); |