While the `waitpid' perlop retries on EINTR, it preserves the
`errno == EINTR' value after eventual success of the underlying
wait4/waitpid syscall. Preserving `$!' confuses
IO::Uncompress::Base::close into saving `$!' in the
IO::Uncompress::Base::saveErrorString call. Saving `$!' there
caused the `$mbfh->close' call to fail in
PublicInbox::MboxReader::_mbox_from in t/solver_git.t when
accessing remote URLs (`lei blob --no-mail
69df7d5 -I $rurl').
So now we always clobber `$!' after successful `waitpid' perlops
to ensure subsequent calls don't misreport errors.
Only noticed when testing on FreeBSD 13.5 without IO::KQueue
while chasing t/solver_git.t regression I noticed on Debian 13.x
$AWAIT_PIDS{$pid} = \@cb_args if @cb_args;
# provide synchronous API
if (defined(wantarray) || (!$in_loop && !@cb_args)) {
- my $ret = waitpid($pid, 0);
+ my $ret = waitpid($pid, 0); # n.b. Perl auto retries on EINTR
if ($ret == $pid) {
+ # prevent IO::Uncompress::Base::close from giving $!
+ # to IO::Uncompress::Base::saveErrorString:
+ $! = 0;
my $cb_args = delete $AWAIT_PIDS{$pid};
@cb_args = @$cb_args if !@cb_args && $cb_args;
await_cb($pid, @cb_args);