From: Niels Provos Date: Sun, 20 Jul 2008 23:31:28 +0000 (+0000) Subject: add a signal and free the base for reinit test X-Git-Tag: release-2.0.1-alpha~232 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a4e2f52a4467af1ce6724d04df14fc98a6f06359;p=libevent add a signal and free the base for reinit test svn:r915 --- diff --git a/test/regress.c b/test/regress.c index 1fd7c30a..f1539f66 100644 --- a/test/regress.c +++ b/test/regress.c @@ -479,12 +479,14 @@ test_periodictimeout(void) } #ifndef WIN32 +static void signal_cb(int fd, short event, void *arg); + extern struct event_base *current_base; static void test_fork(void) { int status; - struct event ev; + struct event ev, sig_ev; pid_t pid; setup_test("After fork: "); @@ -495,6 +497,9 @@ test_fork(void) if (event_add(&ev, NULL) == -1) exit(1); + signal_set(&sig_ev, SIGALRM, signal_cb, &ev); + signal_add(&sig_ev, NULL); + if ((pid = fork()) == 0) { /* in the child */ if (event_reinit(current_base) == -1) { @@ -502,10 +507,14 @@ test_fork(void) exit(1); } + signal_del(&sig_ev); + called = 0; event_dispatch(); + event_base_free(current_base); + /* we do not send an EOF; simple_read_cb requires an EOF * to set test_ok. we just verify that the callback was * called. */ @@ -515,6 +524,8 @@ test_fork(void) /* wait for the child to read the data */ sleep(1); + signal_del(&sig_ev); + write(pair[0], TEST1, strlen(TEST1)+1); if (waitpid(pid, &status, 0) == -1) {