diff options
author | Philip Guenthe <guenther@cvs.openbsd.org> | 2010-08-04 06:05:27 +0000 |
---|---|---|
committer | Philip Guenthe <guenther@cvs.openbsd.org> | 2010-08-04 06:05:27 +0000 |
commit | 229cb0abe499341c6c44466a019203dce763271d (patch) | |
tree | cea565d411f8faedb89dc8abe59f31cb37be5d68 | |
parent | 6ffcfa1d9047b1f465b1635475db626d0b95c9fd (diff) |
Regression test for the recent rfork+kqueue fix
-rw-r--r-- | regress/sys/kern/rfork/kqueue/Makefile | 5 | ||||
-rw-r--r-- | regress/sys/kern/rfork/kqueue/kqueue.c | 50 |
2 files changed, 55 insertions, 0 deletions
diff --git a/regress/sys/kern/rfork/kqueue/Makefile b/regress/sys/kern/rfork/kqueue/Makefile new file mode 100644 index 00000000000..7a3dcf68cc5 --- /dev/null +++ b/regress/sys/kern/rfork/kqueue/Makefile @@ -0,0 +1,5 @@ +# $OpenBSD: Makefile,v 1.1 2010/08/04 06:05:26 guenther Exp $ + +PROG=kqueue + +.include <bsd.regress.mk> diff --git a/regress/sys/kern/rfork/kqueue/kqueue.c b/regress/sys/kern/rfork/kqueue/kqueue.c new file mode 100644 index 00000000000..f21fadc5798 --- /dev/null +++ b/regress/sys/kern/rfork/kqueue/kqueue.c @@ -0,0 +1,50 @@ +/* $OpenBSD: kqueue.c,v 1.1 2010/08/04 06:05:26 guenther Exp $ */ +/* + * Written by Philip Guenther <guenther@openbsd.org>, 2010 Public Domain. + * + * Verify that having a process exit while it has knotes attached to it + * that are from a kqueue that is open in another process doesn't cause + * problems. + */ +#include <sys/param.h> +#include <sys/event.h> +#include <sys/time.h> +#include <sys/wait.h> +#include <err.h> +#include <fcntl.h> +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +int +main(int argc, char *argv[]) +{ + struct kevent ev; + int status; + int kq; + + if ((kq = kqueue()) < 0) + err(1, "kqueue"); + + signal(SIGINT, SIG_IGN); + EV_SET(&ev, SIGINT, EVFILT_SIGNAL, EV_ADD|EV_ENABLE, 0, 0, 0); + + switch(rfork(RFPROC)) { + case -1: + err(1, "rfork"); + case 0: + if (kevent(kq, &ev, 1, NULL, 0, NULL)) + err(1, "kevent"); + raise(SIGINT); + _exit(0); + } + + if (wait(&status) < 0) + err(1, "wait"); + + if (!WIFEXITED(status)) + err(1, "child error"); + + return WEXITSTATUS(status) != 0; +} |