cvs commit: qpsmtpd/plugins/queue qmail-queue

[email protected] (Matt Sergeant)
Newsgroups perl.cvs.qpsmtpd
Message-ID <[email protected]>
cvsuser     03/10/09 10:21:49

  Modified:    plugins/queue qmail-queue
  Log:
  Use POSIX::dup2() instead of open() with <& since I found the latter failed
  regularly for me - POSIX::dup2() was just plain more reliable. Odd, I know.
  
  Revision  Changes    Path
  1.5       +7 -4      qpsmtpd/plugins/queue/qmail-queue
  
  Index: qmail-queue
  ===================================================================
  RCS file: /cvs/public/qpsmtpd/plugins/queue/qmail-queue,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -w -r1.4 -r1.5
  --- qmail-queue	30 Aug 2003 15:13:04 -0000	1.4
  +++ qmail-queue	9 Oct 2003 17:21:49 -0000	1.5
  @@ -18,6 +18,8 @@
   
   =cut
   
  +use POSIX ();
  +
   sub register {
     my ($self, $qp, @args) = @_;
     $self->register_hook("queue", "queue_handler");
  @@ -88,13 +90,12 @@
         exit 3;
       }
   
  -    # save the original STDIN and STDOUT
  +    # save the original STDIN and STDOUT in case exec() fails below
       open(SAVE_STDIN, "<&STDIN");
       open(SAVE_STDOUT, ">&STDOUT");
   
  -    # what are those exit values for?  Why don't we die with a useful error message?
  -    open(STDIN, "<&MESSAGE_READER") or exit 4;
  -    open(STDOUT, "<&ENVELOPE_READER") or exit 5;
  +    POSIX::dup2(fileno(MESSAGE_READER), 0) or die "Unable to dup MESSAGE_READER: $!";
  +    POSIX::dup2(fileno(ENVELOPE_READER), 1) or die "Unable to dup ENVELOPE_READER: $!";
   
       $self->log(7, "Queuing to $queue_exec");
   
  @@ -104,6 +105,8 @@
       open(STDIN, "<&SAVE_STDIN");
       open(STDOUT, ">&SAVE_STDOUT");
   
  +    # NB: The "if not $rc" is redundant since exec() won't return if it
  +    # succeeds.
       exit 6 if not $rc;
     }
   }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.