summaryrefslogtreecommitdiffstats
path: root/linux-user/mmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'linux-user/mmap.c')
-rw-r--r--linux-user/mmap.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index c082138..b4ca107 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -46,6 +46,22 @@ void mmap_unlock(void)
pthread_mutex_unlock(&mmap_mutex);
}
}
+
+/* Grab lock to make sure things are in a consistent state after fork(). */
+void mmap_fork_start(void)
+{
+ if (mmap_lock_count)
+ abort();
+ pthread_mutex_lock(&mmap_mutex);
+}
+
+void mmap_fork_end(int child)
+{
+ if (child)
+ pthread_mutex_init(&mmap_mutex, NULL);
+ else
+ pthread_mutex_unlock(&mmap_mutex);
+}
#else
/* We aren't threadsafe to start with, so no need to worry about locking. */
void mmap_lock(void)
OpenPOWER on IntegriCloud