-# Copyright (C) 2016-2020 all contributors <meta@public-inbox.org>
+# Copyright (C) 2016-2021 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
# Default spam filter class for wrapping spamc(1)
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;