+sub _close ($;$) {
+ my ($self, $wait) = @_;
+ my ($fh, $pid) = delete(@$self{qw(fh pid)});
+ my $ret = defined($fh) ? close($fh) : '';
+ return $ret unless defined($pid) && $self->{ppid} == $$;
+ if ($wait) { # caller cares about the exit status:
+ # synchronous wait via defined(wantarray) on awaitpid:
+ defined(${$self->{pp_chld_err}}) or $wait = awaitpid($pid);
+ ($? = ${$self->{pp_chld_err}}) and $ret = '';
+ } else {
+ awaitpid($pid); # depends on $in_loop or not
+ }
+ $ret;