]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/ProcessPipe.pm
www: label sections and hopefully improve navigation
[public-inbox.git] / lib / PublicInbox / ProcessPipe.pm
index e088c1053f0b08877a277f281f3192925bac791d..943405ff07bd56692d8919ad3f3537407b7c3643 100644 (file)
@@ -15,13 +15,22 @@ sub READ { sysread($_[0]->{fh}, $_[1], $_[2], $_[3] || 0) }
 
 sub READLINE { readline($_[0]->{fh}) }
 
-sub CLOSE { delete($_[0]->{fh}) }
+sub CLOSE {
+       my $fh = delete($_[0]->{fh});
+       my $ret = defined $fh ? close($fh) : '';
+       my $pid = delete $_[0]->{pid};
+       if (defined $pid) {
+               waitpid($pid, 0);
+               $ret = '' if $?;
+       }
+       $ret;
+}
 
 sub FILENO { fileno($_[0]->{fh}) }
 
 sub DESTROY {
-       delete($_[0]->{fh});
-       waitpid($_[0]->{pid}, 0);
+       CLOSE(@_);
+       undef;
 }
 
 sub pid { $_[0]->{pid} }