[gnome-settings-daemon/gnome-3-10] common: Check the exit status of hotplug scripts correctly



commit 3868331eeb445703db5191555d8d21aba457be4e
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Apr 25 15:42:39 2014 +0200

    common: Check the exit status of hotplug scripts correctly
    
    Instead of comparing the shell's exit code by hand, use
    g_spawn_check_exit_status() to get the script's exit code.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=710791

 plugins/common/gsd-input-helper.c |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/plugins/common/gsd-input-helper.c b/plugins/common/gsd-input-helper.c
index f81809e..4f90b03 100644
--- a/plugins/common/gsd-input-helper.c
+++ b/plugins/common/gsd-input-helper.c
@@ -499,6 +499,7 @@ run_custom_command (GdkDevice              *device,
                     CustomCommand           command)
 {
         GSettings *settings;
+        GError *error = NULL;
         char *cmd;
         char *argv[7];
         int exit_status;
@@ -531,15 +532,25 @@ run_custom_command (GdkDevice              *device,
         g_free (out);
 
         rc = g_spawn_sync (g_get_home_dir (), argv, NULL, G_SPAWN_SEARCH_PATH,
-                           NULL, NULL, NULL, NULL, &exit_status, NULL);
+                           NULL, NULL, NULL, NULL, &exit_status, &error);
 
-        if (rc == FALSE)
-                g_warning ("Couldn't execute command '%s', verify that this is a valid command.", cmd);
+        if (rc == FALSE) {
+                g_warning ("Couldn't execute command '%s', verify that this is a valid command: %s", cmd, 
error->message);
+                g_clear_error (&error);
+        }
 
         g_free (argv[0]);
         g_free (argv[4]);
 
-        return (exit_status == 1);
+        if (!g_spawn_check_exit_status (exit_status, &error)) {
+                if (g_error_matches (error, G_SPAWN_EXIT_ERROR, 1)) {
+                        g_clear_error (&error);
+                        return TRUE;
+                }
+                g_clear_error (&error);
+        }
+
+        return FALSE;
 }
 
 GList *


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]