diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2002-08-06 13:21:34 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2002-08-06 13:21:34 +0800 |
commit | 3f8d6fddb31765e20d66e78778c1916ea8618c36 (patch) | |
tree | 59ca79b0cbbf155e269fe6f8b68639c07d6027f8 /camel | |
parent | 115a2836e1dc2826e389d25e12f0ed5f96c86cef (diff) | |
download | gsoc2013-evolution-3f8d6fddb31765e20d66e78778c1916ea8618c36.tar.gz gsoc2013-evolution-3f8d6fddb31765e20d66e78778c1916ea8618c36.tar.zst gsoc2013-evolution-3f8d6fddb31765e20d66e78778c1916ea8618c36.zip |
If writing to the sendmail pipe fails, wait for the sendmail process to
2002-08-06 Jeffrey Stedfast <fejj@ximian.com>
* providers/sendmail/camel-sendmail-transport.c
(sendmail_send_to): If writing to the sendmail pipe fails, wait
for the sendmail process to exit before returning. Fixes bug
#19636.
svn path=/trunk/; revision=17711
Diffstat (limited to 'camel')
-rw-r--r-- | camel/ChangeLog | 7 | ||||
-rw-r--r-- | camel/providers/sendmail/camel-sendmail-transport.c | 32 |
2 files changed, 27 insertions, 12 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index ef540ba517..c543d51eef 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,10 @@ +2002-08-06 Jeffrey Stedfast <fejj@ximian.com> + + * providers/sendmail/camel-sendmail-transport.c + (sendmail_send_to): If writing to the sendmail pipe fails, wait + for the sendmail process to exit before returning. Fixes bug + #19636. + 2002-08-06 Not Zed <NotZed@Ximian.com> * providers/pop3/camel-pop3-folder.c (cmd_list): Add messageinfo diff --git a/camel/providers/sendmail/camel-sendmail-transport.c b/camel/providers/sendmail/camel-sendmail-transport.c index 604d7f293d..1af237f239 100644 --- a/camel/providers/sendmail/camel-sendmail-transport.c +++ b/camel/providers/sendmail/camel-sendmail-transport.c @@ -122,14 +122,14 @@ sendmail_send_to (CamelTransport *transport, CamelMimeMessage *message, g_strerror (errno)); return FALSE; } - + /* Block SIGCHLD so the calling application doesn't notice * sendmail exiting before we do. */ sigemptyset (&mask); sigaddset (&mask, SIGCHLD); sigprocmask (SIG_BLOCK, &mask, &omask); - + pid = fork (); switch (pid) { case -1: @@ -140,39 +140,47 @@ sendmail_send_to (CamelTransport *transport, CamelMimeMessage *message, sigprocmask (SIG_SETMASK, &omask, NULL); g_free (argv); return FALSE; - case 0: /* Child process */ nullfd = open ("/dev/null", O_RDWR); dup2 (fd[0], STDIN_FILENO); - /* dup2 (nullfd, STDOUT_FILENO); - dup2 (nullfd, STDERR_FILENO);*/ + /*dup2 (nullfd, STDOUT_FILENO); + dup2 (nullfd, STDERR_FILENO);*/ close (nullfd); close (fd[1]); - + execv (SENDMAIL_PATH, (char **)argv); _exit (255); } g_free (argv); - + /* Parent process. Write the message out. */ close (fd[0]); out = camel_stream_fs_new_with_fd (fd[1]); if (camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), out) == -1 - || camel_stream_close(out) == -1) { + || camel_stream_close (out) == -1) { camel_object_unref (CAMEL_OBJECT (out)); camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Could not send message: %s"), - strerror(errno)); + g_strerror (errno)); + + /* Wait for sendmail to exit. */ + while (waitpid (pid, &wstat, 0) == -1 && errno == EINTR) + ; + + sigprocmask (SIG_SETMASK, &omask, NULL); + return FALSE; } + camel_object_unref (CAMEL_OBJECT (out)); - + /* Wait for sendmail to exit. */ while (waitpid (pid, &wstat, 0) == -1 && errno == EINTR) ; + sigprocmask (SIG_SETMASK, &omask, NULL); - + if (!WIFEXITED (wstat)) { camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("sendmail exited with signal %s: " @@ -193,7 +201,7 @@ sendmail_send_to (CamelTransport *transport, CamelMimeMessage *message, } return FALSE; } - + return TRUE; } |