Skip to content

Commit

Permalink
StartUnixWorker(): don't exit() on fork() failure
Browse files Browse the repository at this point in the history
... but let the caller handle the failure.

Not to stop working completely just because of fork() failure during a reload.
  • Loading branch information
Al2Klimov committed Oct 30, 2020
1 parent e9b8fc2 commit 96ee6f1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/cli/daemoncommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,17 @@ static pid_t StartUnixWorker(const std::vector<std::string>& configs, bool close
case -1:
Log(LogCritical, "cli")
<< "fork() failed with error code " << errno << ", \"" << Utility::FormatErrorNumber(errno) << "\"";
exit(EXIT_FAILURE);

try {
Application::InitializeBase();
} catch (const std::exception& ex) {
Log(LogCritical, "cli")
<< "Failed to re-initialize thread pool after forking (parent): " << DiagnosticInformation(ex);
exit(EXIT_FAILURE);
}

(void)sigprocmask(SIG_UNBLOCK, &l_UnixWorkerSignals, nullptr);
return -1;

case 0:
try {
Expand Down

0 comments on commit 96ee6f1

Please sign in to comment.