You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by jm...@apache.org on 2007/09/24 21:34:41 UTC
svn commit: r578928 - /spamassassin/trunk/spamassassin.raw
Author: jm
Date: Mon Sep 24 12:34:39 2007
New Revision: 578928
URL: http://svn.apache.org/viewvc?rev=578928&view=rev
Log:
bug 5626: install a signal handler for SIGHUP, SIGINT, SIGPIPE and SIGTERM which will remove leftover temp files
Modified:
spamassassin/trunk/spamassassin.raw
Modified: spamassassin/trunk/spamassassin.raw
URL: http://svn.apache.org/viewvc/spamassassin/trunk/spamassassin.raw?rev=578928&r1=578927&r2=578928&view=diff
==============================================================================
--- spamassassin/trunk/spamassassin.raw (original)
+++ spamassassin/trunk/spamassassin.raw Mon Sep 24 12:34:39 2007
@@ -349,6 +349,8 @@
###########################################################################
+setup_sig_handlers();
+
# Everything below here needs ArchiveIterator ...
my $iter = new Mail::SpamAssassin::ArchiveIterator(
{
@@ -409,10 +411,12 @@
###########################################################################
+my $mail; # global, so signal handler can clean it up; bug 5626
+
# make sure it only returns false values so that result_sub() isn't called...
sub wanted {
my $dataref = $_[3];
- my $mail = $spamtest->parse($dataref);
+ $mail = $spamtest->parse($dataref);
$count++;
# This is a short cut -- doing white/black-list? Do it and return quickly.
@@ -431,6 +435,7 @@
}
$mail->finish();
+ $mail = undef;
return 1;
}
@@ -441,6 +446,7 @@
if ( !$opt{'test-mode'} ) {
print $spamtest->remove_spamassassin_markup ($mail);
$mail->finish();
+ $mail = undef;
return 1;
}
else {
@@ -451,6 +457,7 @@
#
my $new_mail =
$spamtest->parse( $spamtest->remove_spamassassin_markup($mail) );
+
$mail->finish();
$mail = $new_mail;
}
@@ -463,13 +470,14 @@
my $new_mail =
$spamtest->parse( $spamtest->remove_spamassassin_markup($mail) );
$mail->finish();
+ $mail = $new_mail;
my $failed;
- if ( $opt{'report'} && !$spamtest->report_as_spam($new_mail) ) {
+ if ( $opt{'report'} && !$spamtest->report_as_spam($mail) ) {
$failed = 'report';
}
- if ( $opt{'revoke'} && !$spamtest->revoke_as_spam($new_mail) ) {
+ if ( $opt{'revoke'} && !$spamtest->revoke_as_spam($mail) ) {
$failed = 'revoke';
}
@@ -478,7 +486,8 @@
warn "spamassassin: for more information, re-run with -D option to see debug output\n";
}
- $new_mail->finish();
+ $mail->finish();
+ $mail = undef;
return 1;
}
@@ -499,9 +508,30 @@
# clean up after ourselves
$mail->finish();
+ $mail = undef;
+
$status->finish();
return 1;
+}
+
+###########################################################################
+
+sub setup_sig_handlers {
+ $SIG{HUP} = \&kill_handler;
+ $SIG{INT} = \&kill_handler;
+ $SIG{TERM} = \&kill_handler;
+ $SIG{PIPE} = \&kill_handler;
+}
+
+sub kill_handler {
+ my ($sig) = @_;
+ info("spamassassin: killed by SIG$sig");
+ if ($mail) {
+ $mail->finish(); # bug 5626: remove temp files etc.
+ $mail = undef;
+ }
+ exit 0;
}
# ---------------------------------------------------------------------------