]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Spamcheck/Spamc.pm
spamcheck/spamc: use localized slurp to read from spamc
[public-inbox.git] / lib / PublicInbox / Spamcheck / Spamc.pm
index b6098669fc3c41a0584c76912b4f0c21cad8f5e9..3ba2c3c9eab2708ca8d7fc11facb47b0801d24a2 100644 (file)
@@ -23,19 +23,11 @@ sub spamcheck {
 
        my $rdr = { 0 => _msg_to_fh($self, $msg) };
        my ($fh, $pid) = popen_rd($self->{checkcmd}, undef, $rdr);
-       my $r;
        unless (ref $out) {
                my $buf = '';
                $out = \$buf;
        }
-again:
-       do {
-               $r = sysread($fh, $$out, 65536, length($$out));
-       } while (defined($r) && $r != 0);
-       unless (defined $r) {
-               goto again if $!{EINTR};
-               die "read failed: $!";
-       }
+       $$out = do { local $/; <$fh> };
        close $fh or die "close failed: $!";
        waitpid($pid, 0);
        ($? || $$out eq '') ? 0 : 1;