[anjuta] debug-manager: use g_spawn_sync() instead of fork() and waitpid()
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] debug-manager: use g_spawn_sync() instead of fork() and waitpid()
- Date: Sun, 18 Nov 2012 09:43:16 +0000 (UTC)
commit b3ca60227b7415bda872dc85a434d225545b9ec0
Author: Carl-Anton Ingmarsson <ca ingmarsson gmail com>
Date: Sat Nov 17 10:20:19 2012 +0100
debug-manager: use g_spawn_sync() instead of fork() and waitpid()
...in attach_process_update().
https://bugzilla.gnome.org/show_bug.cgi?id=688545
plugins/debug-manager/start.c | 21 +++++++++++----------
1 files changed, 11 insertions(+), 10 deletions(-)
---
diff --git a/plugins/debug-manager/start.c b/plugins/debug-manager/start.c
index 5a6ba77..4ef6d3e 100644
--- a/plugins/debug-manager/start.c
+++ b/plugins/debug-manager/start.c
@@ -598,8 +598,9 @@ static void
attach_process_update (AttachProcess * ap)
{
gchar *tmp, *tmp1, *cmd;
- gint ch_pid;
gchar *shell;
+ gchar *argv[4];
+ GError *err = NULL;
GtkTreeStore *store;
gboolean result;
@@ -618,20 +619,20 @@ attach_process_update (AttachProcess * ap)
cmd = g_strconcat ("ps axw -H -o pid,user,start_time,args > ", tmp, NULL);
#endif
shell = anjuta_util_user_shell ();
- ch_pid = fork ();
- if (ch_pid == 0)
+ argv[0] = shell;
+ argv[1] = "-c";
+ argv[2] = cmd;
+ argv[3] = NULL;
+ if (!g_spawn_sync (NULL, argv, NULL, 0, NULL, NULL, NULL, NULL, NULL, &err))
{
- execlp (shell, shell, "-c", cmd, NULL);
- }
- if (ch_pid < 0)
- {
- anjuta_util_dialog_error_system (NULL, errno,
- _("Unable to execute: %s."), cmd);
+ anjuta_util_dialog_error (NULL, _("Unable to execute: \"%s\". "
+ "The returned error was: \"%s\"."), cmd, err->message);
+ g_error_free (err);
g_free (tmp);
g_free (cmd);
return;
}
- waitpid (ch_pid, NULL, 0);
+
g_free (cmd);
result = g_file_get_contents (tmp, &tmp1, NULL, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]