cvs commit: qpsmtpd qpsmtpd-forkserver

[email protected] (Matt Sergeant)
Newsgroups perl.cvs.qpsmtpd
Message-ID <[email protected]>
cvsuser     04/06/16 13:27:51

  Modified:    .        qpsmtpd-forkserver
  Log:
  Make signal handling slightly more stable
  
  Revision  Changes    Path
  1.4       +10 -2     qpsmtpd/qpsmtpd-forkserver
  
  Index: qpsmtpd-forkserver
  ===================================================================
  RCS file: /cvs/public/qpsmtpd/qpsmtpd-forkserver,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -w -r1.3 -r1.4
  --- qpsmtpd-forkserver	15 Apr 2004 02:19:01 -0000	1.3
  +++ qpsmtpd-forkserver	16 Jun 2004 20:27:51 -0000	1.4
  @@ -27,6 +27,7 @@
   my %childstatus = ();
   
   sub REAPER {
  +  $SIG{CHLD} = \&REAPER;
     while ( defined(my $chld = waitpid(-1, WNOHANG)) ){
       last unless $chld > 0;
       warn("$$ cleaning up after $chld\n");
  @@ -34,7 +35,15 @@
     }
   }
   
  +sub HUNTSMAN {
  +  $SIG{CHLD} = 'DEFAULT';
  +  kill 'INT' => keys %childstatus;
  +  exit(0);
  +}
  +
   $SIG{CHLD} = \&REAPER;
  +$SIG{INT} = \&HUNTSMAN;
  +$SIG{TERM} = \&HUNTSMAN;
   
   # establish SERVER socket, bind and listen.
   my $server = IO::Socket::INET->new(LocalPort => $PORT,
  @@ -86,8 +95,7 @@
   
       close($server);
   
  -    $SIG{CHLD} = $SIG{HUP} = $SIG{PIPE} = $SIG{INT} = 
  -        $SIG{TERM} = $SIG{QUIT} = 'DEFAULT';
  +    $SIG{$_} = 'DEFAULT' for keys %SIG;
       
       my $localsockaddr = getsockname($client);
       my ($lport, $laddr) = sockaddr_in($localsockaddr);
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.