]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
lei: fix idempotent STDERR redirect in workers
authorEric Wong <e@80x24.org>
Wed, 15 Nov 2023 09:21:42 +0000 (09:21 +0000)
committerEric Wong <e@80x24.org>
Thu, 16 Nov 2023 10:56:51 +0000 (10:56 +0000)
This is needed to support forking from already-forked lei workers
and $lei->{2} is already STDERR.

Fixes: e015c3742f91 (lei: use autodie where appropriate, 2023-10-17)
lib/PublicInbox/LEI.pm

index 460aed401c92fa5cbd8d9c5827105b0a5b60069a..8d235b372a1b78c5597d6b6d20e143d8b8760833 100644 (file)
@@ -581,7 +581,7 @@ sub _lei_atfork_child {
                close($_) for (grep(defined, delete @$self{qw(0 1 2 sock)}));
                delete $cfg->{-lei_store};
        } else { # worker, Net::NNTP (Net::Cmd) uses STDERR directly
-               open STDERR, '+>&', $self->{2};
+               open STDERR, '+>&='.fileno($self->{2}); # idempotent w/ fileno
                STDERR->autoflush(1);
                $self->{2} = \*STDERR;
                POSIX::setpgid(0, $$) // die "setpgid(0, $$): $!";