Support SIGTERM

git-svn-id: https://svn.perl.org/qpsmtpd/trunk@188 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
Matt Sergeant 2003-11-02 17:36:36 +00:00
parent 199179eddc
commit ad5e1b6fff

View File

@ -23,6 +23,10 @@ tie %ready, 'Tie::RefHash';
my $server; my $server;
my $select; my $select;
our $QUIT = 0;
$SIG{INT} = $SIG{TERM} = sub { $QUIT++ };
sub main { sub main {
my $class = shift; my $class = shift;
my %opts = (LocalPort => 25, Reuse => 1, Listen => SOMAXCONN, @_); my %opts = (LocalPort => 25, Reuse => 1, Listen => SOMAXCONN, @_);
@ -34,7 +38,9 @@ sub main {
$select = IO::Select->new($server); $select = IO::Select->new($server);
my $res = Net::DNS::Resolver->new; my $res = Net::DNS::Resolver->new;
while (1) { # TODO - make this more graceful - let all current SMTP sessions finish
# before quitting!
while (!$QUIT) {
foreach my $client ($select->can_read(1)) { foreach my $client ($select->can_read(1)) {
if ($client == $server) { if ($client == $server) {
my $client_addr; my $client_addr;