]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/OnDestroy.pm
on_destroy: support PID owner guard
[public-inbox.git] / lib / PublicInbox / OnDestroy.pm
index 841f87d45eabe27ea676536f64268a88127a4953..65ebd7dcf574f5aa72243add2b0df55f355d794a 100644 (file)
@@ -10,6 +10,11 @@ sub new {
 
 sub DESTROY {
        my ($cb, @args) = @{$_[0]};
+       if (!ref($cb)) {
+               my $pid = $cb;
+               return if $pid != $$;
+               $cb = shift @args;
+       }
        $cb->(@args) if $cb;
 }