diff finch/libgnt/gntmain.c @ 19171:9f7587b86b0d

propagate from branch 'tmpbranch' (head e6743aa2d424749cd40350df703d079ef61fd5ce) to branch 'im.pidgin.soc.2007.finchfeat' (head a87f346863ddc48e5705c2c555c7ed842325a9a3)
author Eric Polino <aluink@pidgin.im>
date Sun, 22 Jul 2007 01:28:19 +0000
parents 7a5025b8698c 09db6fec9dce
children 33201366bcd4
line wrap: on
line diff
--- a/finch/libgnt/gntmain.c	Thu Jul 19 10:35:11 2007 +0000
+++ b/finch/libgnt/gntmain.c	Sun Jul 22 01:28:19 2007 +0000
@@ -312,7 +312,7 @@
 	                                 But irssi does this, so I am going to assume the
 	                                 crashes were caused by some other stuff. */
 
-	g_printerr("gntmain: setting up IO\n");
+	g_printerr("gntmain: setting up IO (%d)\n", channel_read_callback);
 }
 
 static gboolean
@@ -649,9 +649,21 @@
 }
 
 #if GLIB_CHECK_VERSION(2,4,0)
+typedef struct
+{
+	void (*callback)(int status, gpointer data);
+	gpointer data;
+} ChildProcess;
+
 static void
 reap_child(GPid pid, gint status, gpointer data)
 {
+	ChildProcess *cp = data;
+	if (cp->callback) {
+		cp->callback(status, cp->data);
+	}
+	g_free(cp);
+	clean_pid();
 	wm->mode = GNT_KP_MODE_NORMAL;
 	clear();
 	setup_io();
@@ -660,10 +672,12 @@
 #endif
 
 gboolean gnt_giveup_console(const char *wd, char **argv, char **envp,
-		gint *stin, gint *stout, gint *sterr)
+		gint *stin, gint *stout, gint *sterr,
+		void (*callback)(int status, gpointer data), gpointer data)
 {
 #if GLIB_CHECK_VERSION(2,4,0)
 	GPid pid = 0;
+	ChildProcess *cp = NULL;
 
 	if (!g_spawn_async_with_pipes(wd, argv, envp,
 			G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
@@ -671,9 +685,12 @@
 			&pid, stin, stout, sterr, NULL))
 		return FALSE;
 
+	cp = g_new0(ChildProcess, 1);
+	cp->callback = callback;
+	cp->data = data;
 	g_source_remove(channel_read_callback);
 	wm->mode = GNT_KP_MODE_WAIT_ON_CHILD;
-	g_child_watch_add(pid, reap_child, NULL);
+	g_child_watch_add(pid, reap_child, cp);
 
 	return TRUE;
 #else