]> Sergey Matveev's repositories - public-inbox.git/blob - lib/PublicInbox/ParentPipe.pm
ds: avoid unnecessary timer for waitpid
[public-inbox.git] / lib / PublicInbox / ParentPipe.pm
1 # Copyright (C) 2016-2020 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
3
4 # only for PublicInbox::Daemon, allows worker processes to be
5 # notified if the master process dies.
6 package PublicInbox::ParentPipe;
7 use strict;
8 use parent qw(PublicInbox::DS);
9 use PublicInbox::Syscall qw(EPOLLIN EPOLLONESHOT);
10
11 sub new ($$$) {
12         my ($class, $pipe, $worker_quit) = @_;
13         my $self = bless { cb => $worker_quit }, $class;
14         $self->SUPER::new($pipe, EPOLLIN|EPOLLONESHOT);
15 }
16
17 # master process died, time to call worker_quit ourselves
18 sub event_step {
19         $_[0]->close; # PublicInbox::DS::close
20         $_[0]->{cb}->();
21 }
22
23 1;