diff options
author | Eric Wong <e@80x24.org> | 2021-01-10 12:15:00 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-01-12 03:51:42 +0000 |
commit | b90e8d6e02852c47d0c08198d8c7afb5dbe008d7 (patch) | |
tree | ea3b399fba66acbd5b67bb5d1b983340ddcc17d3 /lib/PublicInbox/LEI.pm | |
parent | f4cf089b427d07bedb80fcfbe79d84234ad92a75 (diff) | |
download | public-inbox-b90e8d6e02852c47d0c08198d8c7afb5dbe008d7.tar.gz |
This lets us call dwaitpid long before a process exits and not have to wait around for it. This is advantageous for lei where we can run dwaitpid on the pager as soon as we spawn it, instead of waiting for a client socket to go away on DESTROY.
Diffstat (limited to 'lib/PublicInbox/LEI.pm')
-rw-r--r-- | lib/PublicInbox/LEI.pm | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index a5658e6d..12e227d2 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -607,7 +607,8 @@ sub start_pager { my $rdr = { 0 => $r, 1 => $self->{1}, 2 => $self->{2} }; $self->{1} = $w; $self->{2} = $w if -t $self->{2}; - $self->{'pager.pid'} = spawn([$pager], $env, $rdr); + my $pid = spawn([$pager], $env, $rdr); + dwaitpid($pid, undef, $self->{sock}); $env->{GIT_PAGER_IN_USE} = 'true'; # we may spawn git } @@ -689,7 +690,7 @@ sub lazy_start { my @st = stat($path) or die "stat($path): $!"; my $dev_ino_expect = pack('dd', $st[0], $st[1]); # dev+ino pipe(my ($eof_r, $eof_w)) or die "pipe: $!"; - my $oldset = PublicInbox::Sigfd::block_signals(); + my $oldset = PublicInbox::DS::block_signals(); if ($nfd == 1) { require IO::FDPass; $recv_3fds = sub { map { IO::FDPass::recv($_[0]) } (0..2) }; @@ -736,7 +737,7 @@ sub lazy_start { } else { # wake up every second to accept signals if we don't # have signalfd or IO::KQueue: - PublicInbox::Sigfd::sig_setmask($oldset); + PublicInbox::DS::sig_setmask($oldset); PublicInbox::DS->SetLoopTimeout(1000); } PublicInbox::DS->SetPostLoopCallback(sub { @@ -801,9 +802,6 @@ sub oneshot { sub DESTROY { my ($self) = @_; $self->{1}->autoflush(1); - if (my $pid = delete $self->{'pager.pid'}) { - dwaitpid($pid, undef, $self->{sock}); - } } 1; |