Initialize child_watch_count to 1, so that we don't miss the very first
authorMatthias Clasen <mclasen@redhat.com>
Mon, 8 Nov 2004 15:34:26 +0000 (15:34 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Mon, 8 Nov 2004 15:34:26 +0000 (15:34 +0000)
2004-11-08  Matthias Clasen  <mclasen@redhat.com>

* glib/gmain.c: Initialize child_watch_count to 1, so
that we don't miss the very first child if it exits
before we set up the child watch. In that case we had
previously source->count == child_watch_count == 0,
causing g_child_watch_check() to skip the waitpid()
call.  (#154827, Gustavo Carneiro)

* glib/gmain.c (g_child_watch_source_init_single)
(g_child_watch_source_init_multi_threaded): Use sigaction()
instead of signal().  (#136867, Jonas Jonsson, patch by
Archana Shah)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-6
ChangeLog.pre-2-8
glib/gmain.c

index ead6b15..07ce92a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2004-11-08  Matthias Clasen  <mclasen@redhat.com>
+       
+       * glib/gmain.c: Initialize child_watch_count to 1, so 
+       that we don't miss the very first child if it exits 
+       before we set up the child watch. In that case we had 
+       previously source->count == child_watch_count == 0, 
+       causing g_child_watch_check() to skip the waitpid() 
+       call.  (#154827, Gustavo Carneiro)
+
+       * glib/gmain.c (g_child_watch_source_init_single) 
+       (g_child_watch_source_init_multi_threaded): Use sigaction()
+       instead of signal().  (#136867, Jonas Jonsson, patch by
+       Archana Shah)
+
 2004-11-07  Matthias Clasen  <mclasen@redhat.com>
 
        * glib/gutils.c (g_get_any_init): Work around an bug
index ead6b15..07ce92a 100644 (file)
@@ -1,3 +1,17 @@
+2004-11-08  Matthias Clasen  <mclasen@redhat.com>
+       
+       * glib/gmain.c: Initialize child_watch_count to 1, so 
+       that we don't miss the very first child if it exits 
+       before we set up the child watch. In that case we had 
+       previously source->count == child_watch_count == 0, 
+       causing g_child_watch_check() to skip the waitpid() 
+       call.  (#154827, Gustavo Carneiro)
+
+       * glib/gmain.c (g_child_watch_source_init_single) 
+       (g_child_watch_source_init_multi_threaded): Use sigaction()
+       instead of signal().  (#136867, Jonas Jonsson, patch by
+       Archana Shah)
+
 2004-11-07  Matthias Clasen  <mclasen@redhat.com>
 
        * glib/gutils.c (g_get_any_init): Work around an bug
index ead6b15..07ce92a 100644 (file)
@@ -1,3 +1,17 @@
+2004-11-08  Matthias Clasen  <mclasen@redhat.com>
+       
+       * glib/gmain.c: Initialize child_watch_count to 1, so 
+       that we don't miss the very first child if it exits 
+       before we set up the child watch. In that case we had 
+       previously source->count == child_watch_count == 0, 
+       causing g_child_watch_check() to skip the waitpid() 
+       call.  (#154827, Gustavo Carneiro)
+
+       * glib/gmain.c (g_child_watch_source_init_single) 
+       (g_child_watch_source_init_multi_threaded): Use sigaction()
+       instead of signal().  (#136867, Jonas Jonsson, patch by
+       Archana Shah)
+
 2004-11-07  Matthias Clasen  <mclasen@redhat.com>
 
        * glib/gutils.c (g_get_any_init): Work around an bug
index ead6b15..07ce92a 100644 (file)
@@ -1,3 +1,17 @@
+2004-11-08  Matthias Clasen  <mclasen@redhat.com>
+       
+       * glib/gmain.c: Initialize child_watch_count to 1, so 
+       that we don't miss the very first child if it exits 
+       before we set up the child watch. In that case we had 
+       previously source->count == child_watch_count == 0, 
+       causing g_child_watch_check() to skip the waitpid() 
+       call.  (#154827, Gustavo Carneiro)
+
+       * glib/gmain.c (g_child_watch_source_init_single) 
+       (g_child_watch_source_init_multi_threaded): Use sigaction()
+       instead of signal().  (#136867, Jonas Jonsson, patch by
+       Archana Shah)
+
 2004-11-07  Matthias Clasen  <mclasen@redhat.com>
 
        * glib/gutils.c (g_get_any_init): Work around an bug
index ead6b15..07ce92a 100644 (file)
@@ -1,3 +1,17 @@
+2004-11-08  Matthias Clasen  <mclasen@redhat.com>
+       
+       * glib/gmain.c: Initialize child_watch_count to 1, so 
+       that we don't miss the very first child if it exits 
+       before we set up the child watch. In that case we had 
+       previously source->count == child_watch_count == 0, 
+       causing g_child_watch_check() to skip the waitpid() 
+       call.  (#154827, Gustavo Carneiro)
+
+       * glib/gmain.c (g_child_watch_source_init_single) 
+       (g_child_watch_source_init_multi_threaded): Use sigaction()
+       instead of signal().  (#136867, Jonas Jonsson, patch by
+       Archana Shah)
+
 2004-11-07  Matthias Clasen  <mclasen@redhat.com>
 
        * glib/gutils.c (g_get_any_init): Work around an bug
index 9fb7d5e..c522aba 100644 (file)
@@ -266,7 +266,7 @@ enum {
   CHILD_WATCH_INITIALIZED_THREADED
 };
 static gint child_watch_init_state = CHILD_WATCH_UNINITIALIZED;
-static gint child_watch_count = 0;
+static gint child_watch_count = 1;
 static gint child_watch_wake_up_pipe[2] = {0, 0};
 #endif /* !G_OS_WIN32 */
 G_LOCK_DEFINE_STATIC (main_context_list);
@@ -3566,12 +3566,17 @@ g_child_watch_signal_handler (int signum)
 static void
 g_child_watch_source_init_single (void)
 {
+  struct sigaction action;
+
   g_assert (! g_thread_supported());
   g_assert (child_watch_init_state == CHILD_WATCH_UNINITIALIZED);
 
   child_watch_init_state = CHILD_WATCH_INITIALIZED_SINGLE;
 
-  signal (SIGCHLD, g_child_watch_signal_handler);
+  action.sa_handler = g_child_watch_signal_handler;
+  sigemptyset (&action.sa_mask);
+  action.sa_flags = SA_RESTART | SA_NOCLDSTOP;
+  sigaction (SIGCHLD, &action, NULL);
 }
 
 static gpointer
@@ -3619,6 +3624,7 @@ static void
 g_child_watch_source_init_multi_threaded (void)
 {
   GError *error = NULL;
+  struct sigaction action;
 
   g_assert (g_thread_supported());
 
@@ -3631,7 +3637,11 @@ g_child_watch_source_init_multi_threaded (void)
   if (g_thread_create (child_watch_helper_thread, NULL, FALSE, &error) == NULL)
     g_error ("Cannot create a thread to monitor child exit status: %s\n", error->message);
   child_watch_init_state = CHILD_WATCH_INITIALIZED_THREADED;
-  signal (SIGCHLD, g_child_watch_signal_handler);
+  action.sa_handler = g_child_watch_signal_handler;
+  sigemptyset (&action.sa_mask);
+  action.sa_flags = SA_RESTART | SA_NOCLDSTOP;
+  sigaction (SIGCHLD, &action, NULL);
 }
 
 static void