On 21 Jul 2004, at 22:37, Nicolas Cesar wrote:

Here is a small plugin I wrote, so I can filter thou dspam. But I want to
make it a general filter plugin:



------------------------------------------------------------- # -*- perl -*- # # a simple filter for the use of dspam and similar.

sub register {
  my ($self, $qp) = @_;
  $self->register_hook("data_post", "mail_handler");
}

sub mail_handler {
  my ($self, $transaction) = @_;

die "Can't fork: $!" unless defined(my $pid = open(my $k, "-|"));
if ($pid) { # parent
while (<$k>) {
$self->log(LOGINFO, "msj: $_");
$transaction->body_write($_);
#process_line($_);
}
close $k;
return (OK, "successfully filtered message.. continuing");
} else {
open(my $filter, "| /usr/local/bin/dspam --feature=chained,noise
--deliver=innocent,spam --mode=toe --user ncesar --stdout")
or return(DECLINED,"Could not open filter!!.. continuing anyway");


      $transaction->header->print($filter);
      $transaction->body_resetpos;
      while (my $line = $transaction->body_getline) {
          print $filter $line;
      }
      close $filter;
      return(DONE,"Child exiting..");

You say your child is exiting, but it doesn't. You need an explicit exit here.


  }
}



Reply via email to