From 67d6c453ec8126739d9588cf35bca3a5293a95fb Mon Sep 17 00:00:00 2001 From: hiro Date: Wed, 25 May 2005 08:59:29 +0000 Subject: replaced popen() with GSpawn. git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@289 ee746299-78ed-0310-b773-934348b2243d --- src/utils.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/utils.c b/src/utils.c index 8fb7cc3d..3a931b44 100644 --- a/src/utils.c +++ b/src/utils.c @@ -2944,29 +2944,18 @@ gint execute_command_line(const gchar *cmdline, gboolean async) gchar *get_command_output(const gchar *cmdline) { - gchar buf[BUFFSIZE]; - FILE *fp; - GString *str; - gchar *ret; + gchar *child_stdout; + gint status; g_return_val_if_fail(cmdline != NULL, NULL); - if ((fp = popen(cmdline, "r")) == NULL) { - FILE_OP_ERROR(cmdline, "popen"); + if (g_spawn_command_line_sync(cmdline, &child_stdout, NULL, &status, + NULL) == FALSE) { + g_warning("Can't execute command: %s\n", cmdline); return NULL; } - str = g_string_new(""); - - while (fgets(buf, sizeof(buf), fp) != NULL) - g_string_append(str, buf); - - pclose(fp); - - ret = str->str; - g_string_free(str, FALSE); - - return ret; + return child_stdout; } gint open_uri(const gchar *uri, const gchar *cmdline) -- cgit v1.2.3