[glib] Add to the pitfalls: fork() and daemon()



commit 5ff803d91f252bfeb4a9cfaf2f94ecdea6e6a687
Author: Ryan Lortie <desrt desrt ca>
Date:   Sat Oct 15 13:27:46 2011 -0400

    Add to the pitfalls: fork() and daemon()

 glib/gthread.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/glib/gthread.c b/glib/gthread.c
index 2bbbce5..e4ccdd8 100644
--- a/glib/gthread.c
+++ b/glib/gthread.c
@@ -126,6 +126,18 @@
  *     used as an alternative. Or you can use the uselocale() function
  *     to change the locale only for the current thread.
  *   </listitem>
+ *   <listitem>
+ *     fork() only takes the calling thread into the child's copy of the
+ *     process image.  If other threads were executing in critical
+ *     sections they could have left mutexes locked which could easily
+ *     cause deadlocks in the new child.  For this reason, you should
+ *     call exit() or exec() as soon as possible in the child and only
+ *     make signal-safe library calls before that.
+ *   </listitem>
+ *   <listitem>
+ *     daemon() uses fork() in a way contrary to what is described
+ *     above.  It should not be used with GLib programs.
+ *   </listitem>
  * </itemizedlist>
  *
  * GLib itself is internally completely thread-safe (all global data is



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]