]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/DirIdle.pm
lei: close inotify FD in forked child
[public-inbox.git] / lib / PublicInbox / DirIdle.pm
index 65896f950f51f756998899bd44a8c44a4442c116..d572c2749f7fc750e0a3ae3cbcf8748b1263ef10 100644 (file)
@@ -84,4 +84,15 @@ sub event_step {
        warn "$self->{inot}->read err: $@\n" if $@;
 }
 
+sub force_close {
+       my ($self) = @_;
+       my $inot = delete $self->{inot} // return;
+       if ($inot->can('fh')) { # Linux::Inotify2 2.3+
+               close($inot->fh) or warn "CLOSE ERROR: $!";
+       } elsif ($inot->isa('Linux::Inotify2')) {
+               require PublicInbox::LI2Wrap;
+               PublicInbox::LI2Wrap::wrapclose($inot);
+       }
+}
+
 1;