diff options
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) { |