Re: mutt/2800: mutt crashes if piped mail to send and sendmail
The following reply was made to PR mutt/2800; it has been noted by GNATS.
From: Michael Elkins <me@xxxxxxxx>
To: bug-any@xxxxxxxxxxxxx
Cc:
Subject: Re: mutt/2800: mutt crashes if piped mail to send and sendmail
fails.
Date: Thu, 29 Mar 2007 20:09:45 -0700
--sdtB3X0nJg68CQEu
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
On Mon, Feb 26, 2007 at 02:47:39AM +0100, mutt-bugs@xxxxxxxxxxxxx wrote:
> This happens because when mutt sees !isatty(0), it sets OPTNOCURSES. But
> yet, when sendmail fails, it attempts to use the internal pager to display
> the sendmail output.
>
> One solution which works for me is to add the following at line #77 of
> main.c:
>
> if (option(OPTNOCURSES))
> Pager="cat";
>
> This causes mutt to cat the output file, rather then paging it or dying
> trying.
>
> Works for me.
I took this idea and modified it a little. It won't change the pager
unless it is currently builtin, just in case the user want's to use
something other than cat. Diff attached.
Contents of muttrc-test:
set sendmail='/no/such/file'
$ ./mutt -F muttrc-test me@xxxxxxxxxxx < muttrc-test
Error sending message, child exited 127 (Exec error.).
Could not send the message.
me
--sdtB3X0nJg68CQEu
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="patch-1.5.15-me.sendmail-pager.1"
# HG changeset patch
# User Michael Elkins <me@xxxxxxxx>
# Date 1175223955 25200
# Node ID cbd1bd45bcae1c8bf30c53bf2259c6089718ae2d
# Parent 798a40b0a9da05db9dbedd9f96ebcc255fcd813b
set $pager to "/bin/cat" when in batch send mode and $pager is currently
"builtin."
diff -r 798a40b0a9da -r cbd1bd45bcae sendlib.c
--- a/sendlib.c Thu Mar 29 15:53:35 2007 -0700
+++ b/sendlib.c Thu Mar 29 20:05:55 2007 -0700
@@ -2187,7 +2187,16 @@ mutt_invoke_sendmail (ADDRESS *from, /*
struct stat st;
if (stat (childout, &st) == 0 && st.st_size > 0)
+ {
+ /* The builtin pager is not available in batch mode, so change it to
+ * something safe if the user has not already done so.
+ */
+ if (option(OPTNOCURSES) && mutt_strcmp(Pager, "builtin") == 0) {
+ FREE(&Pager);
+ Pager = safe_strdup("/bin/cat");
+ }
mutt_do_pager (_("Output of the delivery process"), childout, 0,
NULL);
+ }
}
}
}
--sdtB3X0nJg68CQEu--