diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2005-06-16 06:48:12 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2005-06-16 06:48:12 +0000 |
commit | 2a9f172298a5e2121f1684863da358df56f10697 (patch) | |
tree | 3bd5200442bd913b0ce6da7e4fd620dadc4596b2 /src | |
parent | 899f239a05c28f5ae8ec43bb7719e5ce0da0b2e5 (diff) |
check exit status to detect errors when send messages using commands.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@347 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src')
-rw-r--r-- | src/send_message.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/send_message.c b/src/send_message.c index 81940763..3faef99d 100644 --- a/src/send_message.c +++ b/src/send_message.c @@ -30,6 +30,8 @@ #include <gtk/gtkwindow.h> #include <stdio.h> #include <string.h> +#include <sys/types.h> +#include <sys/wait.h> #include "send_message.h" #include "session.h" @@ -307,6 +309,7 @@ static gint send_message_local(const gchar *command, FILE *fp) gint child_stdin; gchar buf[BUFFSIZE]; gboolean err = FALSE; + gint status; g_return_val_if_fail(command != NULL, -1); g_return_val_if_fail(fp != NULL, -1); @@ -315,8 +318,10 @@ static gint send_message_local(const gchar *command, FILE *fp) argv = strsplit_with_quote(command, " ", 0); - if (g_spawn_async_with_pipes(NULL, argv, NULL, 0, NULL, NULL, &pid, - &child_stdin, NULL, NULL, NULL) == FALSE) { + if (g_spawn_async_with_pipes(NULL, argv, NULL, + G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, + &pid, &child_stdin, NULL, NULL, + NULL) == FALSE) { g_snprintf(buf, sizeof(buf), _("Can't execute command: %s"), command); log_warning("%s\n", buf); @@ -342,6 +347,11 @@ static gint send_message_local(const gchar *command, FILE *fp) } fd_close(child_stdin); + + waitpid(pid, &status, 0); + if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) + err = TRUE; + g_spawn_close_pid(pid); if (err) { |