diff options
author | Bastien Nocera <hadess@hadess.net> | 2014-04-25 15:42:39 +0200 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2014-04-25 15:45:12 +0200 |
commit | 3868331eeb445703db5191555d8d21aba457be4e (patch) | |
tree | 13b919bff9dc3f6fa03d75fef8098551fa620c9a | |
parent | 41f11e665d94384021f8162c84ae6f7cc82c4dde (diff) | |
download | gnome-settings-daemon-3868331eeb445703db5191555d8d21aba457be4e.tar.gz |
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
-rw-r--r-- | 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 f81809e6..4f90b031 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 * |