From ab77d5c80a5a4e57b915dbbf7d100448b20155a6 Mon Sep 17 00:00:00 2001 From: Brendan Cully Date: Thu, 29 Mar 2007 21:08:28 -0700 Subject: [PATCH] Do not page sendmail error in batch mode. (closes: #2800) --- ChangeLog | 8 ++++++++ sendlib.c | 33 +++++++++++++++++++-------------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index e692d1fff..fb69ed25d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-03-29 15:53 -0700 Rocco Rutte (798a40b0a9da) + + * rfc3676.c: f=f handler: Re-add space between quotes and text + +2007-03-29 15:47 -0700 Brendan Cully (51d13afbf24b) + + * doc/Makefile.am: Make -j2 in doc work (closes: #2538) + 2007-03-29 15:23 -0700 Christoph Berg (0514e6b5a67a) * init.c, init.h: Use ~/.muttrc as the default alias_file if no user diff --git a/sendlib.c b/sendlib.c index 3d123be7b..7c6735355 100644 --- a/sendlib.c +++ b/sendlib.c @@ -1925,7 +1925,8 @@ static RETSIGTYPE alarm_handler (int sig) msg (in) temp file containing message to send tempfile (out) if sendmail is put in the background, this points to the temporary file containing the stdout of the - child process */ + child process. If it is NULL, stderr and stdout + are not redirected. */ static int send_msg (const char *path, char **args, const char *msg, char **tempfile) { @@ -1940,7 +1941,7 @@ send_msg (const char *path, char **args, const char *msg, char **tempfile) sigaddset (&set, SIGTSTP); sigprocmask (SIG_BLOCK, &set, NULL); - if (SendmailWait >= 0) + if (SendmailWait >= 0 && tempfile) { char tmp[_POSIX_PATH_MAX]; @@ -1961,16 +1962,19 @@ send_msg (const char *path, char **args, const char *msg, char **tempfile) setsid (); /* next we close all open files */ + close (0); #if defined(OPEN_MAX) - for (fd = 0; fd < OPEN_MAX; fd++) + for (fd = tempfile ? 1 : 3; fd < OPEN_MAX; fd++) close (fd); #elif defined(_POSIX_OPEN_MAX) - for (fd = 0; fd < _POSIX_OPEN_MAX; fd++) + for (fd = tempfile ? 1 : 3; fd < _POSIX_OPEN_MAX; fd++) close (fd); #else - close (0); - close (1); - close (2); + if (tempfile) + { + close (1); + close (2); + } #endif /* now the second fork() */ @@ -1984,7 +1988,7 @@ send_msg (const char *path, char **args, const char *msg, char **tempfile) } unlink (msg); - if (SendmailWait >= 0) + if (SendmailWait >= 0 && tempfile) { /* *tempfile will be opened as stdout */ if (open (*tempfile, O_WRONLY | O_APPEND | O_CREAT | O_EXCL, 0600) < 0) @@ -1993,7 +1997,7 @@ send_msg (const char *path, char **args, const char *msg, char **tempfile) if (dup (1) < 0) _exit (S_ERR); } - else + else if (tempfile) { if (open ("/dev/null", O_WRONLY | O_APPEND) < 0) /* stdout */ _exit (S_ERR); @@ -2007,7 +2011,8 @@ send_msg (const char *path, char **args, const char *msg, char **tempfile) else if (pid == -1) { unlink (msg); - FREE (tempfile); /* __FREE_CHECKED__ */ + if (tempfile) + FREE (tempfile); /* __FREE_CHECKED__ */ _exit (S_ERR); } @@ -2035,7 +2040,7 @@ send_msg (const char *path, char **args, const char *msg, char **tempfile) if (waitpid (pid, &st, 0) > 0) { st = WIFEXITED (st) ? WEXITSTATUS (st) : S_ERR; - if (SendmailWait && st == (0xff & EX_OK)) + if (SendmailWait && st == (0xff & EX_OK) && tempfile) { unlink (*tempfile); /* no longer needed */ FREE (tempfile); /* __FREE_CHECKED__ */ @@ -2045,7 +2050,7 @@ send_msg (const char *path, char **args, const char *msg, char **tempfile) { st = (SendmailWait > 0 && errno == EINTR && SigAlrm) ? S_BKG : S_ERR; - if (SendmailWait > 0) + if (SendmailWait > 0 && tempfile) { unlink (*tempfile); FREE (tempfile); /* __FREE_CHECKED__ */ @@ -2056,7 +2061,7 @@ send_msg (const char *path, char **args, const char *msg, char **tempfile) alarm (0); sigaction (SIGALRM, &oldalrm, NULL); - if (kill (ppid, 0) == -1 && errno == ESRCH) + if (kill (ppid, 0) == -1 && errno == ESRCH && tempfile) { /* the parent is already dead */ unlink (*tempfile); @@ -2174,7 +2179,7 @@ mutt_invoke_sendmail (ADDRESS *from, /* the sender */ args[argslen++] = NULL; - if ((i = send_msg (path, args, msg, &childout)) != (EX_OK & 0xff)) + if ((i = send_msg (path, args, msg, option(OPTNOCURSES) ? NULL : &childout)) != (EX_OK & 0xff)) { if (i != S_BKG) { -- 2.40.0