changeset 14533:497f4e9a0375

[gaim-migrate @ 17254] The Glib timeout was causing reentrency issues, so I reimplemented it with alarm() committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Mon, 11 Sep 2006 21:07:32 +0000
parents b4c04b1891d6
children 79adfd5ac0b9
files gtk/gtkmain.c
diffstat 1 files changed, 10 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/gtk/gtkmain.c	Mon Sep 11 18:34:36 2006 +0000
+++ b/gtk/gtkmain.c	Mon Sep 11 21:07:32 2006 +0000
@@ -89,7 +89,6 @@
 #endif
 
 #ifdef HAVE_SIGNAL_H
-static guint clean_pid_timeout = 0;
 
 /*
  * Lists of signals we wish to catch and those we wish to ignore.
@@ -102,6 +101,7 @@
 	SIGTERM,
 	SIGQUIT,
 	SIGCHLD,
+	SIGALRM,
 	-1
 };
 
@@ -175,14 +175,12 @@
  * during initialization.  But it's not in 0.10.0, so we shouldn't
  * use it.
  */
-static gboolean
-clean_pid(gpointer data)
+static void
+clean_pid()
 {
 	int status;
 	pid_t pid;
 
-	clean_pid_timeout = 0;
-
 	do {
 		pid = waitpid(-1, &status, WNOHANG);
 	} while (pid != 0 && pid != (pid_t)-1);
@@ -194,10 +192,7 @@
 	}
 
 	/* Restore signal catching */
-	signal(SIGCHLD, sighandler);
-
-	/* This timer should not be called again by glib */
-	return FALSE;
+	signal(SIGALRM, sighandler);
 }
 
 char *segfault_message;
@@ -215,9 +210,12 @@
 		abort();
 		break;
 	case SIGCHLD:
-		if (clean_pid_timeout > 0)
-			gaim_timeout_remove(clean_pid_timeout);
-		clean_pid_timeout = gaim_timeout_add(1000, clean_pid, NULL);
+		/* Restore signal catching */
+		signal(SIGCHLD, sighandler);
+		alarm(1);
+		break;
+	case SIGALRM:
+		clean_pid();
 		break;
 	default:
 		gaim_debug_warning("sighandler", "Caught signal %d\n", sig);
@@ -802,8 +800,6 @@
 	gtk_main();
 
 #ifdef HAVE_SIGNAL_H
-	if (clean_pid_timeout > 0)
-		gaim_timeout_remove(clean_pid_timeout);
 	g_free(segfault_message);
 #endif