From 73830410e4336b779c820e90a8604e9e74f38b90 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 27 Oct 2023 22:21:13 +0000 Subject: treewide: use run_qx where appropriate 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. --- lib/PublicInbox/Spamcheck/Spamc.pm | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'lib/PublicInbox/Spamcheck/Spamc.pm') 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; } -- cgit v1.2.3-24-ge0c7