summaryrefslogtreecommitdiff
path: root/ev.c
diff options
context:
space:
mode:
authorroot <root>2007-11-29 17:28:13 +0000
committerroot <root>2007-11-29 17:28:13 +0000
commit756a6378f76a80c595335d4a78ab426cc44d247d (patch)
tree8dfc566a50d530e4c5ca45a2ee3f97e47b314927 /ev.c
parent8d0f4d263d9a5601bb7d419e7db00970e288cb7e (diff)
implement EVFLAG_FORKCHECK
Diffstat (limited to 'ev.c')
-rw-r--r--ev.c17
1 files changed, 17 insertions, 0 deletions
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))