From 756a6378f76a80c595335d4a78ab426cc44d247d Mon Sep 17 00:00:00 2001 From: root Date: Thu, 29 Nov 2007 17:28:13 +0000 Subject: implement EVFLAG_FORKCHECK --- ev.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'ev.c') diff --git a/ev.c b/ev.c index 1f2429c..3518002 100644 --- a/ev.c +++ b/ev.c @@ -906,6 +906,12 @@ loop_init (EV_P_ unsigned int flags) now_floor = mn_now; rtmn_diff = ev_rt_now - mn_now; + /* pid check not overridable via env */ +#ifndef _WIN32 + if (flags & EVFLAG_FORKCHECK) + curpid = getpid (); +#endif + if (!(flags & EVFLAG_NOENV) && !enable_secure () && getenv ("LIBEV_FLAGS")) @@ -1336,8 +1342,19 @@ ev_loop (EV_P_ int flags) ? EVUNLOOP_ONE : EVUNLOOP_CANCEL; + call_pending (EV_A); /* in case we recurse, ensure ordering stays nice and clean */ + while (activecnt) { +#ifndef _WIN32 + if (expect_false (curpid)) /* penalise the forking check even more */ + if (expect_false (getpid () != curpid)) + { + curpid = getpid (); + postfork = 1; + } +#endif + #if EV_FORK_ENABLE /* we might have forked, so queue fork handlers */ if (expect_false (postfork)) -- cgit v1.2.3