From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 1/6] ds: awaitpid: Perl waitpid retries on EINTR automatically
Date: Tue, 26 Sep 2023 07:44:35 +0000 [thread overview]
Message-ID: <20230926074440.392023-2-e@80x24.org> (raw)
In-Reply-To: <20230926074440.392023-1-e@80x24.org>
perlipc(1) man page states both wait + waitpid will retry
on EINTR. Thus there's no need to retry it ourselves.
---
lib/PublicInbox/DS.pm | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm
index 49550b2b..142122a8 100644
--- a/lib/PublicInbox/DS.pm
+++ b/lib/PublicInbox/DS.pm
@@ -32,7 +32,7 @@ use PublicInbox::Syscall qw(%SIGNUM
EPOLLIN EPOLLOUT EPOLLONESHOT EPOLLEXCLUSIVE);
use PublicInbox::Tmpfile;
use PublicInbox::Select;
-use Errno qw(EAGAIN EINVAL ECHILD EINTR);
+use Errno qw(EAGAIN EINVAL ECHILD);
use Carp qw(carp croak);
our @EXPORT_OK = qw(now msg_more awaitpid add_timer add_uniq_timer);
@@ -713,16 +713,13 @@ sub awaitpid {
$AWAIT_PIDS->{$pid} = \@cb_args if @cb_args;
# provide synchronous API
if (defined(wantarray) || (!$in_loop && !@cb_args)) {
- my $ret;
-again:
- $ret = waitpid($pid, 0) // -2;
+ my $ret = waitpid($pid, 0);
if ($ret == $pid) {
my $cb_args = delete $AWAIT_PIDS->{$pid};
@cb_args = @$cb_args if !@cb_args && $cb_args;
await_cb($pid, @cb_args);
} else {
- goto again if $! == EINTR;
- carp "waitpid($pid): $!";
+ carp "waitpid($pid) => $ret ($!)";
delete $AWAIT_PIDS->{$pid};
}
return $ret;
next prev parent reply other threads:[~2023-09-26 7:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-26 7:44 [PATCH 0/6] waitpid-related cleanups Eric Wong
2023-09-26 7:44 ` Eric Wong [this message]
2023-09-26 7:44 ` [PATCH 2/6] auto_reap: waitpid never returns undef Eric Wong
2023-09-26 7:44 ` [PATCH 3/6] lei_blob: use ProcessPipe to eliminate a waitpid call Eric Wong
2023-09-26 7:44 ` [PATCH 4/6] fetch: fix missing chdir arg for error reporting Eric Wong
2023-09-26 7:44 ` [PATCH 5/6] spamcheck/spamc: rely on ProcessPipe instead of waitpid Eric Wong
2023-09-26 7:44 ` [PATCH 6/6] spawn: add run_wait to simplify spawn+waitpid use Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230926074440.392023-2-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).