better variable names and code documentation

This commit is contained in:
Isaac Connor 2021-02-03 09:50:13 -05:00
parent be1db1ff20
commit 8a99665311
1 changed files with 6 additions and 5 deletions

View File

@ -436,18 +436,19 @@ sub start {
return;
}
# We have to block SIGCHLD during fork to prevent races while we setup our records for it
my $sigset = POSIX::SigSet->new;
my $blockset = POSIX::SigSet->new(SIGCHLD);
sigprocmask(SIG_BLOCK, $blockset, $sigset) or Fatal("Can't block SIGCHLD: $!");
# Apparently the child closing the db connection can affect the parent.
zmDbDisconnect();
if ( my $cpid = fork() ) {
if ( my $child_pid = fork() ) {
$dbh = zmDbConnect(1);
# This logReinit is required. Not sure why.
logReinit();
$process->{pid} = $cpid;
$process->{pid} = $child_pid;
$process->{started} = time();
delete $process->{pending};
@ -456,9 +457,9 @@ sub start {
.", pid = $process->{pid}\n"
);
$cmd_hash{$process->{command}} = $pid_hash{$cpid} = $process;
$cmd_hash{$process->{command}} = $pid_hash{$child_pid} = $process;
sigprocmask(SIG_SETMASK, $sigset) or Fatal("Can't restore SIGCHLD: $!");
} elsif ( defined($cpid) ) {
} elsif ( defined($child_pid) ) {
# Child process
# Force reconnection to the db. $dbh got copied, but isn't really valid anymore.