[Xfce4-commits] [xfce/exo] 02/03: Revert "Fix StartupNotify (Bug 9570, thanks Thaddaeus)"

noreply at xfce.org noreply at xfce.org
Tue May 19 13:07:54 CEST 2015


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

bluesabre pushed a commit to branch master
in repository xfce/exo.

commit a1e13024bf85505e8100e98c5d4a1d8930e2a34e
Author: Sean Davis <smd.seandavis at gmail.com>
Date:   Mon May 18 20:03:07 2015 -0400

    Revert "Fix StartupNotify (Bug 9570, thanks Thaddaeus)"
    
    This reverts commit 3a2c05bd68f924f5c8bd530a2fe8f4cc5b671b16.
---
 exo-helper/exo-helper.c |   52 ++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 49 insertions(+), 3 deletions(-)

diff --git a/exo-helper/exo-helper.c b/exo-helper/exo-helper.c
index aba3749..37d8901 100644
--- a/exo-helper/exo-helper.c
+++ b/exo-helper/exo-helper.c
@@ -359,6 +359,8 @@ exo_helper_execute (ExoHelper   *helper,
   gint          pid;
   const gchar  *real_parameter = parameter;
 
+  // FIXME: startup-notification
+
   g_return_val_if_fail (EXO_IS_HELPER (helper), FALSE);
   g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
   g_return_val_if_fail (screen == NULL || GDK_IS_SCREEN (screen), FALSE);
@@ -397,14 +399,58 @@ exo_helper_execute (ExoHelper   *helper,
         continue;
 
       /* try to run the command */
-      succeed = xfce_spawn_on_screen (screen, NULL, argv, NULL, G_SPAWN_SEARCH_PATH, helper->startup_notify, gtk_get_current_event_time (), NULL, &err);
+      succeed = gdk_spawn_on_screen (screen, NULL, argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH, NULL, NULL, &pid, &err);
 
       /* cleanup */
       g_strfreev (argv);
 
-      /* check if we should retry with the next command */
+      /* check if the execution was successful */
       if (G_LIKELY (succeed))
-        break;
+        {
+          /* determine the current time */
+          g_get_current_time (&previous);
+
+          /* wait up to 5 seconds to see whether the command worked */
+          for (;;)
+            {
+              /* check if the command exited with an error */
+              result = waitpid (pid, &status, WNOHANG);
+              if (result < 0)
+                {
+                  /* something weird happened */
+                  err = g_error_new_literal (G_FILE_ERROR, g_file_error_from_errno (errno), g_strerror (errno));
+                  succeed = FALSE;
+                  break;
+                }
+              else if (result > 0 && status != 0)
+                {
+                  /* the command failed */
+                  err = g_error_new_literal (G_FILE_ERROR, g_file_error_from_errno (EIO), g_strerror (EIO));
+                  succeed = FALSE;
+                  break;
+                }
+              else if (result == pid)
+                {
+                  /* the command succeed */
+                  succeed = TRUE;
+                  break;
+                }
+
+              /* determine the current time */
+              g_get_current_time (&current);
+
+              /* check if the command is still running after 5 seconds (which indicates that the command worked) */
+              if (((current.tv_sec - previous.tv_sec) * 1000ll + (current.tv_usec - previous.tv_usec) / 1000ll) > 5000ll)
+                break;
+
+              /* wait some time */
+              g_usleep (50 * 1000);
+            }
+
+          /* check if we should retry with the next command */
+          if (G_LIKELY (succeed))
+            break;
+        }
     }
 
   /* propagate the error */

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


More information about the Xfce4-commits mailing list