diff options
author | Masao Uebayashi <uebayasi@cvs.openbsd.org> | 2015-08-13 10:26:55 +0000 |
---|---|---|
committer | Masao Uebayashi <uebayasi@cvs.openbsd.org> | 2015-08-13 10:26:55 +0000 |
commit | 2473dded657655a4301e30a2aa64e3b771216770 (patch) | |
tree | 803179f33d43a06ddbe408220547a5bb51a3b0d1 /regress | |
parent | cc1d8b37bdb89879525c0286ace116fd4ae04e26 (diff) |
NOTE_FORK|NOTE_TRACK knote can track grandchild processes. Wait for
both child/grandchild process events.
Diffstat (limited to 'regress')
-rw-r--r-- | regress/sys/kern/kqueue/kqueue-process.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/regress/sys/kern/kqueue/kqueue-process.c b/regress/sys/kern/kqueue/kqueue-process.c index 0c602593998..d4dfa8d02e9 100644 --- a/regress/sys/kern/kqueue/kqueue-process.c +++ b/regress/sys/kern/kqueue/kqueue-process.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kqueue-process.c,v 1.7 2015/08/02 02:42:22 uebayasi Exp $ */ +/* $OpenBSD: kqueue-process.c,v 1.8 2015/08/13 10:26:54 uebayasi Exp $ */ /* * Written by Artur Grabowski <art@openbsd.org> 2002 Public Domain */ @@ -105,18 +105,24 @@ do_process(void) kill(pid2, SIGUSR1); /* sync 2.1 */ kill(pid, SIGUSR1); /* sync 2 */ + /* Wait for child's exit. */ if (wait(&status) < 0) err(1, "wait"); + /* Wait for child-child's exec/exit to receive two events at once. */ + sleep(1); - for (i = 0; i < 1; i++) { - /* make sure we get an exit note */ + for (i = 0; i < 2; i++) { ASS(kevent(kq, NULL, 0, &ke, 1, &ts) == 1, warnx("didn't receive event")); ASSX(ke.filter == EVFILT_PROC); switch (ke.fflags) { case NOTE_EXIT: ASSX((pid_t)ke.ident == pid); - fprintf(stderr, "exit %d\n", pid); + fprintf(stderr, "child exit %d\n", pid); + break; + case NOTE_EXEC | NOTE_EXIT: + ASSX((pid_t)ke.ident == pid2); + fprintf(stderr, "child-child exec/exit %d\n", pid2); break; default: errx(1, "kevent returned weird event 0x%x pid %d", |