summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonsta <[email protected]>2015-03-25 15:21:34 +0300
committerStefano Karapetsas <[email protected]>2015-04-05 19:18:11 +0200
commit1fef7c809727b7d3d6197be82092fe09d189fb25 (patch)
tree6f0d281c80bc7a7618f33c1bfc1fd6b95d723935
parentcbc9dcdeaf600348f3dccb5fa95bd6149865c48f (diff)
downloadmate-desktop-1fef7c809727b7d3d6197be82092fe09d189fb25.tar.bz2
mate-desktop-1fef7c809727b7d3d6197be82092fe09d189fb25.tar.xz
mate-desktop-item: add a child watch if "do not reap child" flag set
similar to https://git.gnome.org/browse/gnome-panel/commit/?id=76acc5b avoids double forking with desktop files that have "exec pkexec ..." inside. Closes https://github.com/mate-desktop/mate-desktop/pull/166
-rw-r--r--libmate-desktop/mate-desktop-item.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/libmate-desktop/mate-desktop-item.c b/libmate-desktop/mate-desktop-item.c
index eb004d9..c0ee1da 100644
--- a/libmate-desktop/mate-desktop-item.c
+++ b/libmate-desktop/mate-desktop-item.c
@@ -1721,6 +1721,17 @@ make_environment_for_screen (GdkScreen *screen,
return retval;
}
+static void
+dummy_child_watch (GPid pid,
+ gint status,
+ gpointer user_data)
+{
+ /* Nothing, this is just to ensure we don't double fork
+ * and break pkexec:
+ * https://bugzilla.gnome.org/show_bug.cgi?id=675789
+ */
+}
+
static int
ditem_execute (const MateDesktopItem *item,
const char *exec,
@@ -1749,6 +1760,7 @@ ditem_execute (const MateDesktopItem *item,
char *new_exec, *uris, *temp;
char *exec_locale;
int launched = 0;
+ GPid pid;
#ifdef HAVE_STARTUP_NOTIFICATION
GdkDisplay *gdkdisplay;
SnLauncherContext *sn_context;
@@ -1957,14 +1969,17 @@ ditem_execute (const MateDesktopItem *item,
(do_not_reap_child ? G_SPAWN_DO_NOT_REAP_CHILD : 0) | G_SPAWN_SEARCH_PATH /* flags */,
NULL, /* child_setup_func */
NULL, /* child_setup_func_data */
- &ret /* child_pid */,
+ (do_not_reap_child ? &pid : NULL) /* child_pid */,
error)) {
/* The error was set for us,
* we just can't launch this thingie */
ret = -1;
g_strfreev (real_argv);
break;
+ } else if (do_not_reap_child) {
+ g_child_watch_add (pid, dummy_child_watch, NULL);
}
+
launched ++;
g_strfreev (real_argv);