From: Azat Khuzhin Date: Sat, 26 Dec 2015 23:31:03 +0000 (+0300) Subject: test/regress: main/fork: rewrite assertions by just removing event in callback X-Git-Tag: release-2.1.6-beta~87^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=088d8b39f9f72cd83941bcb9bc261fabfd432eb2;p=libevent test/regress: main/fork: rewrite assertions by just removing event in callback Instead of assigning some variable value (got_child), and schedule exit from loop from that callback, just remove event for that signal, and event loop will exit automatically when there will be no events. --- diff --git a/test/regress.c b/test/regress.c index 4d170820..d200ae35 100644 --- a/test/regress.c +++ b/test/regress.c @@ -817,28 +817,21 @@ end: } #ifndef _WIN32 -static void signal_cb(evutil_socket_t fd, short event, void *arg); #define current_base event_global_current_base_ extern struct event_base *current_base; static void -child_signal_cb(evutil_socket_t fd, short event, void *arg) +fork_signal_cb(evutil_socket_t fd, short events, void *arg) { - struct timeval tv; - int *pint = arg; - - *pint = 1; - - tv.tv_usec = 500000; - tv.tv_sec = 0; - event_loopexit(&tv); + event_del(arg); } + static void test_fork(void) { - int status, got_sigchld = 0; + int status; struct event ev, sig_ev; pid_t pid; @@ -855,7 +848,7 @@ test_fork(void) if (event_add(&ev, NULL) == -1) exit(1); - evsignal_set(&sig_ev, SIGCHLD, child_signal_cb, &got_sigchld); + evsignal_set(&sig_ev, SIGCHLD, fork_signal_cb, &sig_ev); evsignal_add(&sig_ev, NULL); event_base_assert_ok_(current_base); @@ -917,11 +910,6 @@ test_fork(void) event_dispatch(); - if (!got_sigchld) { - fprintf(stdout, "FAILED (sigchld)\n"); - exit(1); - } - evsignal_del(&sig_ev); end: