From 2a9f172298a5e2121f1684863da358df56f10697 Mon Sep 17 00:00:00 2001 From: hiro Date: Thu, 16 Jun 2005 06:48:12 +0000 Subject: 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 --- ChangeLog | 5 +++++ ChangeLog.ja | 5 +++++ src/send_message.c | 14 ++++++++++++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b659b4c6..32746720 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-06-16 + + * src/send_message.c: send_message_local(): check exit status to + detect errors. + 2005-06-16 * src/procmsg.c: procmsg_empty_trash(): unset dirty flag after cleared diff --git a/ChangeLog.ja b/ChangeLog.ja index 52e65ab7..cb0458a4 100644 --- a/ChangeLog.ja +++ b/ChangeLog.ja @@ -1,3 +1,8 @@ +2005-06-16 + + * src/send_message.c: send_message_local(): 終了ステータスをチェック + してエラーを検出するようにした。 + 2005-06-16 * src/procmsg.c: procmsg_empty_trash(): キャッシュ/マークファイルを 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 #include #include +#include +#include #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) { -- cgit v1.2.3