[Xfce4-commits] [xfce/xfce4-session] 06/11: dbus-client: save the program name

noreply at xfce.org noreply at xfce.org
Tue Jun 28 09:26:09 CEST 2016


This is an automated email from the git hooks/post-receive script.

eric pushed a commit to branch master
in repository xfce/xfce4-session.

commit c330fce551c610d69a6a12d7d3d67e73489977db
Author: Eric Koegel <eric.koegel at gmail.com>
Date:   Sun Jun 26 12:47:25 2016 +0300

    dbus-client: save the program name
---
 xfce4-session/xfsm-client.c | 45 +++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 41 insertions(+), 4 deletions(-)

diff --git a/xfce4-session/xfsm-client.c b/xfce4-session/xfsm-client.c
index 9e590c6..8daa286 100644
--- a/xfce4-session/xfsm-client.c
+++ b/xfce4-session/xfsm-client.c
@@ -379,7 +379,7 @@ xfsm_client_get_service_name (XfsmClient *client)
 
 
 static void
-xfsm_client_get_command_line (XfsmClient *client)
+xfsm_client_save_restart_command (XfsmClient *client)
 {
   XfsmProperties *properties = client->properties;
   gchar          *input;
@@ -393,6 +393,9 @@ xfsm_client_get_command_line (XfsmClient *client)
     {
       gchar **strv = g_new0(gchar*, 2);
 
+      /* remove the newline at the end of the string */
+      output[strcspn(output, "\n")] = 0;
+
       strv[0] = output;
       strv[1] = NULL;
 
@@ -401,8 +404,39 @@ xfsm_client_get_command_line (XfsmClient *client)
     }
   else
     {
-      xfsm_verbose ("Failed to get the process command line, error was %s", error->message);
+      xfsm_verbose ("Failed to get the process command line using the command %s, error was %s", input, error->message);
+    }
+
+  g_free (input);
+}
+
+
+
+static void
+xfsm_client_save_program_name (XfsmClient *client)
+{
+  XfsmProperties *properties = client->properties;
+  gchar          *input;
+  gchar          *output = NULL;
+  gint            exit_status;
+  GError         *error = NULL;
+
+  input = g_strdup_printf ("ps -p %u -o comm=", properties->pid);
+
+  if(g_spawn_command_line_sync (input, &output, NULL, &exit_status, &error))
+    {
+      /* remove the newline at the end of the string */
+      output[strcspn(output, "\n")] = 0;
+
+      xfsm_verbose ("%s program name %s", input, output);
+      xfsm_properties_set_string (properties, "Program", output);
+    }
+  else
+    {
+      xfsm_verbose ("Failed to get the process command line using the command %s, error was %s", input, error->message);
     }
+
+  g_free (input);
 }
 
 
@@ -428,8 +462,11 @@ xfsm_client_set_pid (XfsmClient *client,
   /* store the string as well (so we can export it over dbus */
   xfsm_properties_set_string (properties, "ProcessID", pid_str);
 
-  /* get the command line for the process so we can restart it if needed */
-  xfsm_client_get_command_line (client);
+  /* save the command line for the process so we can restart it if needed */
+  xfsm_client_save_restart_command (client);
+
+  /* save the program name */
+  xfsm_client_save_program_name (client);
 
   g_free (pid_str);
 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list