* [PATCH 3/4] ds: improve error handling of synchronous awaitpid
2023-01-19 20:32 6% [PATCH 0/4] qspawn|awaitpid error handling improvements Eric Wong
@ 2023-01-19 20:32 7% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2023-01-19 20:32 UTC (permalink / raw)
To: meta
EINTR needs to be retried for non-kqueue|signalfd users,
and ECHILD indicates a bug in our code.
---
lib/PublicInbox/DS.pm | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm
index c849f515..523d47e4 100644
--- a/lib/PublicInbox/DS.pm
+++ b/lib/PublicInbox/DS.pm
@@ -30,7 +30,7 @@ use Time::HiRes qw(clock_gettime CLOCK_MONOTONIC);
use Scalar::Util qw(blessed);
use PublicInbox::Syscall qw(:epoll);
use PublicInbox::Tmpfile;
-use Errno qw(EAGAIN EINVAL);
+use Errno qw(EAGAIN EINVAL ECHILD EINTR);
use Carp qw(carp croak);
our @EXPORT_OK = qw(now msg_more awaitpid add_timer add_uniq_timer);
@@ -703,13 +703,19 @@ sub awaitpid {
$AWAIT_PIDS->{$pid} //= @cb_args ? \@cb_args : 0;
# provide synchronous API
if (defined(wantarray) || (!$in_loop && !@cb_args)) {
- my $ret = waitpid($pid, 0) // -2;
+ my $ret;
+again:
+ $ret = waitpid($pid, 0) // -2;
if ($ret == $pid) {
my $cb_args = delete $AWAIT_PIDS->{$pid};
@cb_args = @$cb_args if !@cb_args && $cb_args;
await_cb($pid, @cb_args);
- return $ret;
+ } else {
+ goto again if $! == EINTR;
+ carp "waitpid($pid): $!";
+ delete $AWAIT_PIDS->{$pid};
}
+ return $ret;
}
# We could've just missed our SIGCHLD, cover it, here:
enqueue_reap() if $in_loop;
^ permalink raw reply related [relevance 7%]
* [PATCH 0/4] qspawn|awaitpid error handling improvements
@ 2023-01-19 20:32 6% Eric Wong
2023-01-19 20:32 7% ` [PATCH 3/4] ds: improve error handling of synchronous awaitpid Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2023-01-19 20:32 UTC (permalink / raw)
To: meta
Nothing major, but it makes future work easier and more robust.
Eric Wong (4):
qspawn: {quiet} only affects normal command exit
qspawn: psgi_qx: do not call async_pass on errors
ds: improve error handling of synchronous awaitpid
qspawn: drop unnecessary awaitpid import
lib/PublicInbox/DS.pm | 12 +++++++++---
lib/PublicInbox/Qspawn.pm | 25 ++++++++++++-------------
2 files changed, 21 insertions(+), 16 deletions(-)
^ permalink raw reply [relevance 6%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2023-01-19 20:32 6% [PATCH 0/4] qspawn|awaitpid error handling improvements Eric Wong
2023-01-19 20:32 7% ` [PATCH 3/4] ds: improve error handling of synchronous awaitpid Eric Wong
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).