Skip to content

Commit 96ee6f1

Browse files
committed
StartUnixWorker(): don't exit() on fork() failure
... but let the caller handle the failure. Not to stop working completely just because of fork() failure during a reload.
1 parent e9b8fc2 commit 96ee6f1

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/cli/daemoncommand.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,17 @@ static pid_t StartUnixWorker(const std::vector<std::string>& configs, bool close
437437
case -1:
438438
Log(LogCritical, "cli")
439439
<< "fork() failed with error code " << errno << ", \"" << Utility::FormatErrorNumber(errno) << "\"";
440-
exit(EXIT_FAILURE);
440+
441+
try {
442+
Application::InitializeBase();
443+
} catch (const std::exception& ex) {
444+
Log(LogCritical, "cli")
445+
<< "Failed to re-initialize thread pool after forking (parent): " << DiagnosticInformation(ex);
446+
exit(EXIT_FAILURE);
447+
}
448+
449+
(void)sigprocmask(SIG_UNBLOCK, &l_UnixWorkerSignals, nullptr);
450+
return -1;
441451

442452
case 0:
443453
try {

0 commit comments

Comments
 (0)