From fad96ca2ab378b2ff86b8dbe5b6433afa2ac850c Mon Sep 17 00:00:00 2001
From: Alberto Bertogli <albertito@blitiri.com.ar>
Date: Thu, 21 May 2009 23:23:31 -0300
Subject: [PATCH 10/48] Run a function at fork time

Not really used at the moment, but it will in following patches.

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
---
 libfiu/fiu.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/libfiu/fiu.c b/libfiu/fiu.c
index ef06c17..f00ef8f 100644
--- a/libfiu/fiu.c
+++ b/libfiu/fiu.c
@@ -183,6 +183,13 @@ static double randd(void)
 	return (double) randd_xn / UINT_MAX;
 }
 
+/* Function that runs after the process has been forked, at the child. It's
+ * registered via pthread_atfork() in fiu_init(). */
+static void atfork_child(void)
+{
+
+}
+
 
 /*
  * Core API
@@ -206,6 +213,11 @@ int fiu_init(unsigned int flags)
 	enabled_fails_len = 0;
 	enabled_fails_nfree = 0;
 
+	if (pthread_atfork(NULL, NULL, atfork_child) != 0) {
+		ef_wunlock();
+		return -1;
+	}
+
 	initialized = 1;
 
 	ef_wunlock();
-- 
1.6.2.2.646.gb214

