If a user is relying on reference counts to invalidate FDs
(as we do in many places), rely on them instead of explicit
`close'. This forces us to do a better job of managing refs
and avoiding redundant fields which make our code more fragile.
sub _close ($;$) {
my ($self, $wait) = @_;
my ($fh, $pid) = delete(@$self{qw(fh pid)});
- my $ret = defined($fh) ? close($fh) : '';
+ my $ret = (defined($fh) && $wait) ? close($fh) : ($fh = '');
return $ret unless defined($pid) && $self->{ppid} == $$;
if ($wait) { # caller cares about the exit status:
# synchronous wait via defined(wantarray) on awaitpid: