packages: libgnomesu/libgnomesu-mainloop.patch (NEW) - merged from OpenSUSE...

hawk hawk at pld-linux.org
Thu Nov 25 10:37:49 CET 2010


Author: hawk                         Date: Thu Nov 25 09:37:49 2010 GMT
Module: packages                      Tag: HEAD
---- Log message:
- merged from OpenSUSE: use a main loop so we can handle other events
  while waiting for the child (like session exiting)

---- Files affected:
packages/libgnomesu:
   libgnomesu-mainloop.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: packages/libgnomesu/libgnomesu-mainloop.patch
diff -u /dev/null packages/libgnomesu/libgnomesu-mainloop.patch:1.1
--- /dev/null	Thu Nov 25 10:37:49 2010
+++ packages/libgnomesu/libgnomesu-mainloop.patch	Thu Nov 25 10:37:44 2010
@@ -0,0 +1,77 @@
+diff -upr libgnomesu-1.0.0-pre/tools/gnomesu.c libgnomesu-1.0.0-post/tools/gnomesu.c
+--- libgnomesu-1.0.0-pre/tools/gnomesu.c	2004-11-28 12:09:18.000000000 -0600
++++ libgnomesu-1.0.0-post/tools/gnomesu.c	2006-03-20 17:03:44.000000000 -0600
+@@ -33,7 +33,8 @@
+ 
+ static gchar *command = NULL;
+ static gchar *user = NULL;
+-
++static gint   final_status = 0;
++GMainLoop    *main_loop;
+ 
+ static struct poptOption options[] = {
+ 	{ "command", 'c', POPT_ARG_STRING, &command, 0,
+@@ -47,6 +48,12 @@ static struct poptOption options[] = {
+ 	{ NULL, '\0', 0, NULL, 0 }
+ };
+ 
++static void
++child_exit_cb (GPid pid, gint status, gpointer data)
++{
++	final_status = status;
++	g_main_loop_quit (main_loop);
++}
+ 
+ int
+ main (int argc, char *argv[])
+@@ -70,6 +77,8 @@ main (int argc, char *argv[])
+ 		g_value_init (&value, G_TYPE_POINTER));
+ 	pctx = g_value_get_pointer (&value);
+ 
++	main_loop = g_main_loop_new (NULL, FALSE);
++
+ 	if (!command) {
+ 		GList *arglist = NULL;
+ 		gchar *arg, **args;
+@@ -90,8 +99,10 @@ main (int argc, char *argv[])
+ 			if (!gnomesu_spawn_command_async (user, terminal, &pid))
+ 				return 255;
+ 
+-			waitpid (pid, &status, 0);
+-			return WEXITSTATUS (status);
++			g_child_watch_add (pid, child_exit_cb, NULL);
++			g_main_loop_run (main_loop);
++
++			return WEXITSTATUS (final_status);
+ 		}
+ 
+ 		args = g_new0 (gchar *, g_list_length (arglist) + 1);
+@@ -102,11 +113,13 @@ main (int argc, char *argv[])
+ 
+ 		if (!gnomesu_spawn_async (user, args, &pid))
+ 			return 255;
+-		waitpid (pid, &status, 0);
++
++		g_child_watch_add (pid, child_exit_cb, NULL);
++		g_main_loop_run (main_loop);
+ 
+ 		g_list_free (arglist);
+ 		g_free (args);
+-		return WEXITSTATUS (status);
++		return WEXITSTATUS (final_status);
+ 
+ 	} else {
+ 		int status, pid;
+@@ -114,8 +127,10 @@ main (int argc, char *argv[])
+ 		if (!gnomesu_spawn_command_async (user, command, &pid))
+ 			return 255;
+ 
+-		waitpid (pid, &status, 0);
+-		return WEXITSTATUS (status);
++		g_child_watch_add (pid, child_exit_cb, NULL);
++		g_main_loop_run (main_loop);
++
++		return WEXITSTATUS (final_status);
+ 	}
+ 
+ 	return 0;
================================================================


More information about the pld-cvs-commit mailing list