]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei: ensure autoflush(1) is on STDERR
authorEric Wong <e@80x24.org>
Fri, 30 Apr 2021 09:24:34 +0000 (09:24 +0000)
committerEric Wong <e@80x24.org>
Fri, 30 Apr 2021 19:59:45 +0000 (19:59 +0000)
This fixes error reporting for oneshot tests in xt/lei-auth-failure.t

lib/PublicInbox/LEI.pm

index 3468094f53c4c3dda67f06f63c1a8ebf16de4efe..6a82d497f81a1e62266db5d2d01510bc662dbc35 100644 (file)
@@ -500,6 +500,7 @@ sub _lei_atfork_child {
                }
        } else { # worker, Net::NNTP (Net::Cmd) uses STDERR directly
                open STDERR, '+>&='.fileno($self->{2}) or warn "open $!";
+               STDERR->autoflush(1);
        }
        close($_) for (grep(defined, delete @$self{qw(3 old_1 au_done)}));
        if (my $op_c = delete $self->{pkt_op_c}) {
@@ -676,6 +677,7 @@ sub lazy_cb ($$$) {
 sub dispatch {
        my ($self, $cmd, @argv) = @_;
        local $current_lei = $self; # for __WARN__
+       $self->{2}->autoflush(1); # keep stdout buffered until x_it|DESTROY
        dump_and_clear_log("from previous run\n");
        return _help($self, 'no command given') unless defined($cmd);
        # do not support Getopt bundling for this
@@ -1006,7 +1008,6 @@ sub accept_dispatch { # Listener {post_accept} callback
                }
                $i == 4 or return send($sock, 'not enough FDs='.($i-1), MSG_EOR)
        }
-       $self->{2}->autoflush(1); # keep stdout buffered until x_it|DESTROY
        # $ENV_STR = join('', map { "\0$_=$ENV{$_}" } keys %ENV);
        # $buf = "$argc\0".join("\0", @ARGV).$ENV_STR."\0\0";
        substr($buf, -2, 2, '') eq "\0\0" or  # s/\0\0\z//