]> git.pld-linux.org Git - packages/xfce4-session.git/blob - 0001-Use-the-async-spawn-function-of-glib.patch
5e154f264d1fdcd798e7027d4c42fd52515f66c9
[packages/xfce4-session.git] / 0001-Use-the-async-spawn-function-of-glib.patch
1 From dee0200fa5dc4de064f288281ddd13199ba7fcde Mon Sep 17 00:00:00 2001
2 From: Nick Schermer <nick@xfce.org>
3 Date: Fri, 26 Apr 2013 19:46:29 +0200
4 Subject: Use the async spawn function of glib.
5
6 ---
7  xfce4-session/xfsm-startup.c | 45 +++++++++++++++-----------------------------
8  1 file changed, 15 insertions(+), 30 deletions(-)
9
10 diff --git a/xfce4-session/xfsm-startup.c b/xfce4-session/xfsm-startup.c
11 index 911eec6..e43c53c 100644
12 --- a/xfce4-session/xfsm-startup.c
13 +++ b/xfce4-session/xfsm-startup.c
14 @@ -864,6 +864,7 @@ xfsm_startup_start_properties (XfsmProperties *properties,
15    gint             n;
16    const gchar     *current_directory;
17    GPid             pid;
18 +  GError          *error = NULL;
19  
20    /* release any possible old resources related to a previous startup */
21    xfsm_properties_set_default_child_watch (properties);
22 @@ -878,44 +879,28 @@ xfsm_startup_start_properties (XfsmProperties *properties,
23  
24    current_directory = xfsm_properties_get_string (properties, SmCurrentDirectory);
25  
26 -  /* fork a new process for the application */
27 -#ifdef HAVE_VFORK
28 -  /* vfork() doesn't allow you to do anything but call exec*() or _exit(),
29 -   * so if we need to set the working directory, we can't use vfork() */
30 -  if (current_directory == NULL)
31 -    pid = vfork ();
32 -  else
33 -#endif
34 -    pid = fork ();
35 -
36 -  /* handle the child process */
37 -  if (pid == 0)
38 +  if (!g_spawn_async (current_directory,
39 +                      argv, NULL,
40 +                      G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH,
41 +                      NULL, NULL,
42 +                      &pid, &error))
43      {
44 -      /* execute the application here */
45 -      if (current_directory)
46 -        {
47 -          if (chdir (current_directory))
48 -            g_warning ("Unable to chdir to \"%s\": %s", current_directory, strerror (errno));
49 -        }
50 -      execvp (argv[0], argv);
51 -      _exit (127);
52 -    }
53 -
54 -  /* cleanup */
55 -  g_strfreev (argv);
56 +      g_warning ("Unable to launch \"%s\": %s",
57 +                 *argv, error->message);
58 +      g_error_free (error);
59 +      g_strfreev (argv);
60  
61 -  /* check if we failed to fork */
62 -  if (G_UNLIKELY (pid < 0))
63 -    {
64 -      /* tell the user that we failed to fork */
65 -      perror ("Failed to fork new process");
66        return FALSE;
67      }
68  
69 +  xfsm_verbose ("Launched command \"%s\" with PID %dn", *argv, (gint) pid);
70 +
71 +  g_strfreev (argv);
72 +
73    properties->pid = pid;
74  
75    /* set a watch to make sure the child doesn't quit before registering */
76 -  child_watch_data = g_new (XfsmStartupData, 1);
77 +  child_watch_data = g_new0 (XfsmStartupData, 1);
78    child_watch_data->manager = g_object_ref (manager);
79    child_watch_data->properties = properties;
80    g_child_watch_add_full (G_PRIORITY_LOW, properties->pid,
81 -- 
82 1.8.1
83
This page took 0.079607 seconds and 2 git commands to generate.