sub watch_atfork_parent ($) {
my ($self) = @_;
_done_for_now($self);
+ PublicInbox::Sigfd::block_signals();
}
sub imap_idle_requeue ($) { # DS::add_timer callback
return if $self->{quit};
my $idle_todo = $self->{idle_todo};
if ($idle_todo && @$idle_todo) {
- watch_atfork_parent($self);
- while (my $url_intvl = shift(@$idle_todo)) {
- imap_idle_fork($self, $url_intvl);
- }
+ my $oldset = watch_atfork_parent($self);
+ eval {
+ while (my $url_intvl = shift(@$idle_todo)) {
+ imap_idle_fork($self, $url_intvl);
+ }
+ };
+ PublicInbox::Sigfd::sig_setmask($oldset);
+ die $@ if $@;
}
goto(&fs_scan_step) if $self->{mdre};
}
sub poll_fetch_fork ($) { # DS::add_timer callback
my ($self, $intvl, $urls) = @{$_[0]};
return if $self->{quit};
- watch_atfork_parent($self);
- defined(my $pid = fork) or die "fork: $!";
- if ($pid == 0) {
+ my $oldset = watch_atfork_parent($self);
+ my $pid = fork;
+ if (defined($pid) && $pid == 0) {
watch_atfork_child($self);
if ($urls->[0] =~ m!\Aimaps?://!i) {
watch_imap_fetch_all($self, $urls);
}
_exit(0);
}
+ PublicInbox::Sigfd::sig_setmask($oldset);
+ die "fork: $!" unless defined $pid;
$self->{poll_pids}->{$pid} = [ $intvl, $urls ];
PublicInbox::DS::dwaitpid($pid, \&poll_fetch_reap, $self);
}