]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
spamcheck/spamc: rely on ProcessPipe instead of waitpid
authorEric Wong <e@80x24.org>
Tue, 26 Sep 2023 07:44:39 +0000 (07:44 +0000)
committerEric Wong <e@80x24.org>
Tue, 26 Sep 2023 21:02:46 +0000 (21:02 +0000)
We lose error information on CORE::close call, but the
underlying close(2) syscall won't EIO nor ENOSPC on a read-only
side of a pipe.  Perl is already shielding us from EINTR and
EBADF would be a bug in Perl itself.

lib/PublicInbox/Spamcheck/Spamc.pm

index 2f82153249c3555b08a7c6f1953ccbe97414b019..672789172463f43c0cb862c11adcdc9d2ae1bf40 100644 (file)
@@ -21,14 +21,13 @@ sub spamcheck {
        my ($self, $msg, $out) = @_;
 
        my $rdr = { 0 => _msg_to_fh($self, $msg) };
-       my ($fh, $pid) = popen_rd($self->{checkcmd}, undef, $rdr);
+       my $fh = popen_rd($self->{checkcmd}, undef, $rdr);
        unless (ref $out) {
                my $buf = '';
                $out = \$buf;
        }
        $$out = do { local $/; <$fh> };
-       close $fh or die "close failed: $!";
-       waitpid($pid, 0);
+       close $fh; # PublicInbox::ProcessPipe::CLOSE
        ($? || $$out eq '') ? 0 : 1;
 }