[gnome-software/wip/fedora-third-party-wait-status-check] gs-fedora-third-party: Check exit status when calling fedora-third-party



commit 8f94fa79cc1ed018563e85dbb7c10776c41a288c
Author: Milan Crha <mcrha redhat com>
Date:   Fri Apr 8 09:08:57 2022 +0200

    gs-fedora-third-party: Check exit status when calling fedora-third-party
    
    This will catch also when the fedora-third-party crashes or is stopped
    unexpectedly, not only when it's not installed or such errors.

 lib/gs-fedora-third-party.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/lib/gs-fedora-third-party.c b/lib/gs-fedora-third-party.c
index 358fa70f9..6afebc014 100644
--- a/lib/gs-fedora-third-party.c
+++ b/lib/gs-fedora-third-party.c
@@ -298,10 +298,12 @@ gs_fedora_third_party_switch_sync (GsFedoraThirdParty *self,
 
        g_mutex_lock (&self->lock);
        if (gs_fedora_third_party_ensure_executable_locked (self, error)) {
+               gint wait_status = -1;
                args[1] = self->executable;
                args[2] = enable ? "enable" : "disable";
                args[3] = config_only ? "--config-only" : NULL;
-               success = g_spawn_sync (NULL, (gchar **) args, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, 
NULL, NULL, error);
+               success = g_spawn_sync (NULL, (gchar **) args, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, 
NULL, &wait_status, error) &&
+                         g_spawn_check_wait_status (wait_status, error);
        }
        g_mutex_unlock (&self->lock);
 
@@ -366,7 +368,9 @@ gs_fedora_third_party_opt_out_sync (GsFedoraThirdParty *self,
 
        g_mutex_lock (&self->lock);
        if (gs_fedora_third_party_ensure_executable_locked (self, error)) {
-               success = g_spawn_sync (NULL, (gchar **) args, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, 
NULL, NULL, error);
+               gint wait_status = -1;
+               success = g_spawn_sync (NULL, (gchar **) args, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, 
NULL, &wait_status, error) &&
+                         g_spawn_check_wait_status (wait_status, error);
        }
        g_mutex_unlock (&self->lock);
 
@@ -440,9 +444,11 @@ gs_fedora_third_party_list_sync (GsFedoraThirdParty *self,
        if (self->repos == NULL || (g_get_real_time () / G_USEC_PER_SEC) - self->last_update > 12 * 60 * 60) {
                g_clear_pointer (&self->repos, g_hash_table_unref);
                if (gs_fedora_third_party_ensure_executable_locked (self, error)) {
+                       gint wait_status = -1;
                        g_autofree gchar *stdoutput = NULL;
                        args[0] = self->executable;
-                       if (g_spawn_sync (NULL, (gchar **) args, NULL, G_SPAWN_DEFAULT, NULL, NULL, 
&stdoutput, NULL, NULL, error)) {
+                       if (g_spawn_sync (NULL, (gchar **) args, NULL, G_SPAWN_DEFAULT, NULL, NULL, 
&stdoutput, NULL, &wait_status, error) &&
+                           g_spawn_check_wait_status (wait_status, error)) {
                                GHashTable *repos = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, 
g_free);
                                g_auto(GStrv) lines = NULL;
 


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