lib/PublicInbox/LEI.pm | 18 ++++-------------- t/lei.t | 1 + diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index 7ffcf163182cb16d7628c9e95aaa43649bb1a20c..1ea7c9ca5a38e76c716369bec8f6e654d2183c96 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -487,19 +487,14 @@ my ($self, $persist) = @_; # we need to explicitly close things which are on stack if ($persist) { chdir '/' or die "chdir(/): $!"; - my @io = delete @$self{qw(0 1 2 sock)}; - unless ($self->{oneshot}) { - close($_) for @io; - } + close($_) for (grep(defined, delete @$self{qw(0 1 2 sock)})); if (my $cfg = $self->{cfg}) { delete $cfg->{-lei_store}; } } else { # worker, Net::NNTP (Net::Cmd) uses STDERR directly open STDERR, '+>&='.fileno($self->{2}) or warn "open $!"; } - for (delete @$self{qw(3 old_1 au_done)}) { - close($_) if defined($_); - } + close($_) for (grep(defined, delete @$self{qw(3 old_1 au_done)})); if (my $op_c = delete $self->{pkt_op_c}) { close(delete $op_c->{sock}); } @@ -1213,13 +1208,8 @@ my $exit = $main_pkg->can('exit'); # caller may override exit() local $quit = $exit if $exit; local %PATH2CFG; umask(077) // die("umask(077): $!"); - my $self = bless { - oneshot => 1, - 0 => *STDIN{GLOB}, - 1 => *STDOUT{GLOB}, - 2 => *STDERR{GLOB}, - env => \%ENV - }, __PACKAGE__; + my $self = bless { oneshot => 1, env => \%ENV }, __PACKAGE__; + for (0..2) { open($self->{$_}, '+<&=', $_) or die "open fd=$_: $!" } dispatch($self, @ARGV); x_it($self, $self->{child_error}) if $self->{child_error}; } diff --git a/t/lei.t b/t/lei.t index 6d276050adedd4138c46b129aaaa5217074d702a..8211c01d464f30cc38879c5dddbfb129592c9d43 100644 --- a/t/lei.t +++ b/t/lei.t @@ -154,6 +154,7 @@ "error noted with q $fl"); } } lei_ok('sucks', \'yes, but hopefully less every day'); + like($lei_out, qr/loaded features/, 'loaded features shown'); SKIP: { skip 'no curl', 3 unless which('curl'); lei(qw(q --only http://127.0.0.1:99999/bogus/ t:m));