[anjuta] libanjuta: bgo #699326 - Replace fork and execlp with g_spawn_async in resources.c



commit 8879da58c4e49969f459398595ee53a05264eb75
Author: Arnel A. Borja <kyoushuu yahoo com>
Date:   Sun Apr 7 00:24:02 2013 +0800

    libanjuta: bgo #699326 - Replace fork and execlp with g_spawn_async in resources.c

 libanjuta/resources.c |   28 +++++++++++++++-------------
 1 files changed, 15 insertions(+), 13 deletions(-)
---
diff --git a/libanjuta/resources.c b/libanjuta/resources.c
index a915b5a..3f4989c 100644
--- a/libanjuta/resources.c
+++ b/libanjuta/resources.c
@@ -258,25 +258,27 @@ anjuta_res_get_icon_for_file (PropsID props, const gchar *filename)
 void
 anjuta_res_help_search (const gchar * word)
 {
+       GError *error = NULL;
+       gchar **argv = g_new0 (gchar *, 4);
+
+       argv[0] = g_strdup ("devhelp");
+
        if(word)
        {
+               argv[1] = g_strdup ("-s");
+               argv[2] = g_strdup (word);
+
                fprintf(stderr, "Word is %s\n", word);
-               if(fork()==0)
-               {
-                       execlp("devhelp", "devhelp", "-s", word, NULL);
-                       g_warning (_("Cannot execute command: \"%s\""), "devhelp");
-                       _exit(1);
-               }
        }
-       else
+
+       if (g_spawn_async (NULL, argv, NULL, G_SPAWN_SEARCH_PATH,
+                          NULL, NULL, NULL, &error))
        {
-               if(fork()==0)
-               {
-                       execlp("devhelp", "devhelp", NULL);
-                       g_warning (_("Cannot execute command: \"%s\""), "devhelp");
-                       _exit(1);
-               }
+               g_warning (_("Cannot execute command \"%s\": %s"), "devhelp", error->message);
+               g_error_free (error);
        }
+
+       g_strfreev (argv);
 }
 
 void


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