diff options
author | Eric Wong <e@80x24.org> | 2023-10-01 09:54:19 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2023-10-01 22:41:42 +0000 |
commit | 8aa6e36fbd5955db5ee80059729feed1ec6ddaa0 (patch) | |
tree | e210f671f4f0d17a4587b4b5a8af896b29eea3ac /lib/PublicInbox/ProcessPipe.pm | |
parent | 68daebe359cb5836a8b700032f30f475a7e93c94 (diff) | |
download | public-inbox-8aa6e36fbd5955db5ee80059729feed1ec6ddaa0.tar.gz |
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.
Diffstat (limited to 'lib/PublicInbox/ProcessPipe.pm')
-rw-r--r-- | lib/PublicInbox/ProcessPipe.pm | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/PublicInbox/ProcessPipe.pm b/lib/PublicInbox/ProcessPipe.pm index 16971801..ba2c1ecb 100644 --- a/lib/PublicInbox/ProcessPipe.pm +++ b/lib/PublicInbox/ProcessPipe.pm @@ -58,7 +58,7 @@ sub FILENO { fileno($_[0]->{fh}) } 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: |