Ticket #279: process-quarantine.patch

File process-quarantine.patch, 1.7 kB (added by jnorell, 6 years ago)
  • process-quarantine.pl

    old new  
    164164push(@cl_array, "--ham-only") if ($hamonly); # process ham only 
    165165push(@cl_array, "--debug") if ($debug); # turn on debugging mode 
    166166push(@cl_array, "--quiet") if ($quiet); # turn on quiet mode 
     167push(@cl_array, "|| /bin/echo \"DIED: \$?\""); # hacked exit status reporter 
     168 
     169my $cl_command = join(' ', @cl_array); 
    167170 
    168171# Call the subroutine until there are no items left to process 
    169172my $total_items_processed = 0; 
    170173my $total_processing_runs = 0; 
    171174my $items_processed = -1; 
    172175while ($items_processed != 0) { 
    173     $items_processed = system(@cl_array) / 256; 
     176    $items_processed = 0; 
     177    open(CL, "$cl_command |") || die "can't run subroutine: $!\n"; 
     178      while (chomp(my $clout = <CL>)) { 
     179        if ($clout =~ m/^DIED: (\d)+/) { 
     180          $clout =~ s/^DIED: //; 
     181          die "subroutine died with error status $clout"; 
     182        } elsif ($clout =~ m/^(\d)+/) { 
     183           $items_processed .= $clout; 
     184        } else { 
     185          print "$clout\n"; 
     186        } 
     187      } 
     188    close(CL); 
    174189    $total_items_processed += $items_processed; 
    175190    $total_processing_runs++; 
    176191    if ($debug) { 
  • process-quarantine-sub.pl

    old new  
    111111{ 
    112112   my ($msg) = @_; 
    113113 
    114    print $msg . "\n"; 
     114   print STDERR $msg . "\n"; 
    115115   exit 0; 
    116116} 
    117117 
     
    558558# Disconnect from the database 
    559559$dbh->disconnect; 
    560560 
    561 # We're done, return the total number of items processed. 
    562 exit ($spamcount + $hamcount); 
     561# We're done, print the total number of items processed and return. 
     562print ($spamcount + $hamcount); 
     563exit(0);