my @c_opt = qw(c=s@ C=s@ quiet|q);
my @net_opt = (qw(no-torsocks torsocks=s), PublicInbox::LeiQuery::curl_opt());
-my @lxs_opt = qw(remote! local! external! include|I=s@ exclude=s@ only=s@
+my @lxs_opt = qw(remote! local! external! include|I=s@ exclude=s@ only|O=s@
import-remote!);
# we don't support -C as an alias for --find-copies since it's already
}, qw(config-file|system|global|file|f=s), # for conflict detection
qw(edit|e c=s@ C=s@), pass_through('git config') ],
'inspect' => [ 'ITEMS...|--stdin', 'inspect lei/store and/or local external',
- qw(stdin| pretty ascii dir=s), @c_opt ],
+ qw(stdin| pretty ascii dir|d=s), @c_opt ],
'init' => [ '[DIRNAME]', sub {
"initialize storage, default: ".store_path($_[0]);
'path-a|a=s' => 'pre-image pathname associated with OID',
'path-b|b=s' => 'post-image pathname associated with OID',
'git-dir=s@' => 'additional git repository to scan',
-'dir=s inspect' => 'specify a inboxdir, extindex topdir or Xapian shard',
+'dir|d=s inspect' =>
+ 'specify a inboxdir, extindex topdir or Xapian shard',
'proxy=s' => [ 'PROTO://HOST[:PORT]', # shared with curl(1)
"proxy for (e.g. `socks5h://0:9050')" ],
'torsocks=s' => ['VAL|auto|no|yes',
'exclude specified external(s) from search' ],
'include|I=s@ q' => [ 'LOCATION',
'include specified external(s) in search' ],
-'only=s@ q' => [ 'LOCATION',
+'only|O=s@ q' => [ 'LOCATION',
'only use specified external(s) for search' ],
'jobs=s q' => [ '[SEARCH_JOBS][,WRITER_JOBS]',
'control number of search and writer jobs' ],
sub _drop_wq {
my ($self) = @_;
for my $wq (grep(defined, delete(@$self{@WQ_KEYS}))) {
- if ($wq->wq_kill) {
+ if ($wq->wq_kill('-TERM')) {
$wq->wq_close(0, undef, $self);
- } elsif ($wq->wq_kill_old) {
+ } elsif ($wq->wq_kill_old('-TERM')) {
$wq->wq_wait_old(undef, $self);
}
$wq->DESTROY;
fail_handler($_[0], 13, delete $_[0]->{1});
}
-# PublicInbox::OnDestroy callback for SIGINT to take out the entire pgid
-sub sigint_reap {
- my ($pgid) = @_;
- dwaitpid($pgid) if kill('-INT', $pgid);
-}
-
sub fail ($$;$) {
my ($self, $buf, $exit_code) = @_;
local $current_lei = $self;
} else { # worker, Net::NNTP (Net::Cmd) uses STDERR directly
open STDERR, '+>&='.fileno($self->{2}) or warn "open $!";
STDERR->autoflush(1);
+ POSIX::setpgid(0, $$) // die "setpgid(0, $$): $!";
}
close($_) for (grep(defined, delete @$self{qw(3 old_1 au_done)}));
if (my $op_c = delete $self->{pkt_op_c}) {
$cb->(@_) unless PublicInbox::Eml::warn_ignore(@_)
};
}
+ $SIG{TERM} = sub { exit(128 + 15) };
$current_lei = $persist ? undef : $self; # for SIG{__WARN__}
}
if ($buf eq '') {
_drop_wq($self); # EOF, client disconnected
dclose($self);
- } elsif ($buf =~ /\A(STOP|CONT)\z/) {
+ } elsif ($buf =~ /\A(?:STOP|CONT)\z/) {
+ my $sig = "-$buf";
for my $wq (grep(defined, @$self{@WQ_KEYS})) {
- $wq->wq_kill($buf) or $wq->wq_kill_old($buf);
+ $wq->wq_kill($sig) or $wq->wq_kill_old($sig);
}
} else {
die "unrecognized client signal: $buf";
undef;
}
+sub request_umask {
+ my ($lei) = @_;
+ my $s = $lei->{sock} // return;
+ send($s, 'umask', MSG_EOR) // die "send: $!";
+ vec(my $rvec = '', fileno($s), 1) = 1;
+ select($rvec, undef, undef, 2) or die 'timeout waiting for umask';
+ recv($s, my $v, 5, 0) // die "recv: $!";
+ (my $u, $lei->{client_umask}) = unpack('AV', $v);
+ $u eq 'u' or warn "E: recv $v has no umask";
+}
+
1;