diff options
author | Eric Wong <e@80x24.org> | 2023-10-27 22:21:13 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2023-10-28 09:08:18 +0000 |
commit | 73830410e4336b779c820e90a8604e9e74f38b90 (patch) | |
tree | 92962cefd15d77edb12c57d08cc89b0d37110d67 /lib/PublicInbox/Spamcheck | |
parent | ef5bd67cbcdcd8cba2cb8b3718ea90afda6b7ebe (diff) | |
download | public-inbox-73830410e4336b779c820e90a8604e9e74f38b90.tar.gz |
This saves us some code, and is a small step towards getting ProcessIO working with stat, fcntl and other perlops that don't work with tied handles.
Diffstat (limited to 'lib/PublicInbox/Spamcheck')
-rw-r--r-- | lib/PublicInbox/Spamcheck/Spamc.pm | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/lib/PublicInbox/Spamcheck/Spamc.pm b/lib/PublicInbox/Spamcheck/Spamc.pm index cba33a66..798de218 100644 --- a/lib/PublicInbox/Spamcheck/Spamc.pm +++ b/lib/PublicInbox/Spamcheck/Spamc.pm @@ -4,7 +4,7 @@ # Default spam filter class for wrapping spamc(1) package PublicInbox::Spamcheck::Spamc; use v5.12; -use PublicInbox::Spawn qw(popen_rd run_wait); +use PublicInbox::Spawn qw(run_qx run_wait); use IO::Handle; use Fcntl qw(SEEK_SET); @@ -20,14 +20,9 @@ sub new { sub spamcheck { my ($self, $msg, $out) = @_; + $out = \(my $buf = '') unless ref($out); my $rdr = { 0 => _msg_to_fh($self, $msg) }; - my $fh = popen_rd($self->{checkcmd}, undef, $rdr); - unless (ref $out) { - my $buf = ''; - $out = \$buf; - } - $$out = do { local $/; <$fh> }; - close $fh; # PublicInbox::ProcessIO::CLOSE + $$out = run_qx($self->{checkcmd}, undef, $rdr); ($? || $$out eq '') ? 0 : 1; } |