1 # Copyright (C) 2016-2018 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
4 # a tied handle for auto reaping of children tied to a pipe, see perltie(1)
5 package PublicInbox::ProcessPipe;
10 my ($class, $pid, $fh) = @_;
11 bless { pid => $pid, fh => $fh }, $class;
14 sub READ { sysread($_[0]->{fh}, $_[1], $_[2], $_[3] || 0) }
16 sub READLINE { readline($_[0]->{fh}) }
19 my $fh = delete($_[0]->{fh});
20 my $ret = defined $fh ? close($fh) : '';
21 my $pid = delete $_[0]->{pid};
29 sub FILENO { fileno($_[0]->{fh}) }
36 sub pid { $_[0]->{pid} }