-# usage: my %sig = $lei->atfork_child_wq($wq);
-# local @SIG{keys %sig} = values %sig;
-sub atfork_child_wq {
- my ($self, $wq) = @_;
- my ($sock, $l2m_wq_s1);
- (@$self{qw(0 1 2)}, $sock, $l2m_wq_s1) = delete(@$wq{0..4});
- $self->{sock} = $sock if -S $sock;
- $self->{l2m}->{-wq_s1} = $l2m_wq_s1 if $l2m_wq_s1 && -S $l2m_wq_s1;
- %PATH2CFG = ();
- $quit = \&CORE::exit;
- @TO_CLOSE_ATFORK_CHILD = ();
- (__WARN__ => sub { err($self, @_) },
- PIPE => sub {
- $self->x_it(13); # SIGPIPE = 13
- # we need to close explicitly to avoid Perl warning on SIGPIPE
- for my $i (1, 2) {
- next unless $self->{$i} && (-p $self->{$i} || -S _);
- close(delete $self->{$i});
- }
- # trigger the LeiXSearch $done OpPipe:
- syswrite($self->{0}, '!') if $self->{0} && -p $self->{0};
- $SIG{PIPE} = 'DEFAULT';
- die bless(\"$_[0]", 'PublicInbox::SIGPIPE'),
- });
+sub puts ($;@) { out(shift, map { "$_\n" } @_) }
+
+sub child_error { # passes non-fatal curl exit codes to user
+ my ($self, $child_error, $msg) = @_; # child_error is $?
+ $self->err($msg) if $msg;
+ if (my $s = $self->{pkt_op_p} // $self->{sock}) {
+ # send to the parent lei-daemon or to lei(1) client
+ send($s, "child_error $child_error", MSG_EOR);
+ } elsif (!$PublicInbox::DS::in_loop) {
+ $self->{child_error} = $child_error;
+ } # else noop if client disconnected