If *record* is set, avoid writing dead content twice..
commit863a8647da891462492364fab12baf8c9efc076e
authorSteffen "Daode" Nurpmeso <sdaoden@users.sf.net>
Fri, 14 Sep 2012 15:02:38 +0000 (14 17:02 +0200)
committerSteffen "Daode" Nurpmeso <sdaoden@users.sf.net>
Tue, 18 Sep 2012 15:18:42 +0000 (18 17:18 +0200)
treea73b1b9631cc58f2be6c6a238d472b3514a55292
parent582364f9aa82bdb1a610da2f77c24de0f169236c
If *record* is set, avoid writing dead content twice..

If a message cannot be sent it is written to *DEAD*.  However,
if *record* is also set it is written to *DEAD* twice.

It happens to be fixable on Mac OS X Snow Leopard, NetBSD 6,
OpenBSD 5.1 if a lseek(2) call in sendout.c:savemail() is removed.
This lseek(2) call bypasses the Std I/O mechanism.  Well, a very
fflush(3)/fseek(3) combination is defined for POSIX-conforming
systems, and as an extension of the C standard (this is from IEEE
Std 1003.1, 1996 Edition):

   8.2.3.7 fseek(), rewind()
   [.]
   If the most recent operation, other than ftell(), on a given
   stream is fflush(), the file offset in the underlying open
   file description shall be adjusted to reflect the location
   specified by the fseek().

Even then it is questionable wether an application should assume
internals about stdio and, even more, kernel states.  On the
other hand it is completely mysterious to me why the mentioned
stdio libs do not catch that, and on the other hand.  But
i don't know enough of how nail(1) functions and so maybe it's
my fault.

The Heirloom repo doesn't offer any annotate info on these
lines, they are present from the beginning.
This is not politics but a bug.
sendout.c