From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id E320820834 for ; Mon, 26 Jun 2017 03:15:45 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/5] spamc: retry on EINTR Date: Mon, 26 Jun 2017 03:15:42 +0000 Message-Id: <20170626031545.11879-3-e@80x24.org> In-Reply-To: <20170626031545.11879-1-e@80x24.org> References: <20170626031545.11879-1-e@80x24.org> List-Id: Signals can fire on us at any time if we're using blocking sysread. --- lib/PublicInbox/Spamcheck/Spamc.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/Spamcheck/Spamc.pm b/lib/PublicInbox/Spamcheck/Spamc.pm index 30eec95..ba8e44a 100644 --- a/lib/PublicInbox/Spamcheck/Spamc.pm +++ b/lib/PublicInbox/Spamcheck/Spamc.pm @@ -29,10 +29,14 @@ sub spamcheck { my $buf = ''; $out = \$buf; } +again: do { $r = sysread($fh, $$out, 65536, length($$out)); } while (defined($r) && $r != 0); - defined $r or die "read failed: $!"; + unless (defined $r) { + goto again if $!{EINTR}; + die "read failed: $!"; + } close $fh or die "close failed: $!"; waitpid($pid, 0); ($? || $$out eq '') ? 0 : 1; -- EW