On Nov 27, 2004, at 4:44, Matt Sergeant wrote:
On 27 Nov 2004, at 07:47, Robert Spier wrote:
Why are we restoring STDIN/STDOUT after a failed exec, right before we exit?
Bad things happen when that exec fails... especially if the streams get flushed in the wrong place.
Any reason not to do the following? (Second half of patch is the interesting part.)
I must say I wondered that too. I figured Ask was copying C code from qmail-smtpd, but it doesn't appear so.
I think it's leftover from when the code was changed to use POSIX::dup.
In a really old version (from +2 years ago, when the queue code was in Qpsmtpd.pm) it was used to set the readers to filehandle 0 and 1 like this:
close MESSAGE_WRITER or die "could not close message writer in parent";
close ENVELOPE_WRITER or die "could not close envelope writer in parent";
open(STDIN, "<&MESSAGE_READER") or die "b1";
open(STDOUT, "<&ENVELOPE_READER") or die "b2"; unless (exec '/var/qmail/bin/qmail-queue') {
die "should never be here!";
}
- ask
-- http://www.askbjoernhansen.com/
