Commit 6a8b67698473f09e07b0d5698b93ee55dd66f205

Authored by Monsta
Committed by Stefano Karapetsas
1 parent c36bd02a
Exists in upstream-1.8

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
Showing 1 changed file with 16 additions and 1 deletions   Show diff stats
libmate-desktop/mate-desktop-item.c
... ... @@ -1721,6 +1721,17 @@ make_environment_for_screen (GdkScreen *screen,
1721 1721 return retval;
1722 1722 }
1723 1723  
  1724 +static void
  1725 +dummy_child_watch (GPid pid,
  1726 + gint status,
  1727 + gpointer user_data)
  1728 +{
  1729 + /* Nothing, this is just to ensure we don't double fork
  1730 + * and break pkexec:
  1731 + * https://bugzilla.gnome.org/show_bug.cgi?id=675789
  1732 + */
  1733 +}
  1734 +
1724 1735 static int
1725 1736 ditem_execute (const MateDesktopItem *item,
1726 1737 const char *exec,
... ... @@ -1749,6 +1760,7 @@ ditem_execute (const MateDesktopItem *item,
1749 1760 char *new_exec, *uris, *temp;
1750 1761 char *exec_locale;
1751 1762 int launched = 0;
  1763 + GPid pid;
1752 1764 #ifdef HAVE_STARTUP_NOTIFICATION
1753 1765 GdkDisplay *gdkdisplay;
1754 1766 SnLauncherContext *sn_context;
... ... @@ -1957,14 +1969,17 @@ ditem_execute (const MateDesktopItem *item,
1957 1969 (do_not_reap_child ? G_SPAWN_DO_NOT_REAP_CHILD : 0) | G_SPAWN_SEARCH_PATH /* flags */,
1958 1970 NULL, /* child_setup_func */
1959 1971 NULL, /* child_setup_func_data */
1960   - &ret /* child_pid */,
  1972 + (do_not_reap_child ? &pid : NULL) /* child_pid */,
1961 1973 error)) {
1962 1974 /* The error was set for us,
1963 1975 * we just can't launch this thingie */
1964 1976 ret = -1;
1965 1977 g_strfreev (real_argv);
1966 1978 break;
  1979 + } else if (do_not_reap_child) {
  1980 + g_child_watch_add (pid, dummy_child_watch, NULL);
1967 1981 }
  1982 +
1968 1983 launched ++;
1969 1984  
1970 1985 g_strfreev (real_argv);
... ...