Fixed FreeBSD build

This commit is contained in:
Dmitry Wagin 2022-09-03 23:21:01 +03:00
parent f1910fdc54
commit 1c5c8d26d8
1 changed files with 10 additions and 1 deletions

View File

@ -88,7 +88,11 @@
#if defined(__linux__) || defined(__FreeBSD__)
#include <execinfo.h>
#include <signal.h>
#if defined(__linux__)
#include <sys/prctl.h>
#elif defined(__FreeBSD__)
#include <sys/procctl.h>
#endif
#ifdef ALLOC_INSTRUMENTATION
#include <cxxabi.h>
#endif
@ -2394,10 +2398,15 @@ int main(int argc, char* argv[]) {
g_network->getLocalAddress(), opts.rollsize, opts.maxLogsSize, opts.logFolder, "trace", opts.logGroup);
auto m = startSystemMonitor(opts.dataFolder, opts.dcId, opts.zoneId, opts.zoneId);
TraceEvent(SevDebug, "StartingFlowProcess").detail("FlowProcessName", opts.flowProcessName);
#if defined(__linux__) || defined(__FreeBSD__)
#if defined(__linux__)
prctl(PR_SET_PDEATHSIG, SIGTERM);
if (getppid() == 1) /* parent already died before prctl */
flushAndExit(FDB_EXIT_SUCCESS);
#elif defined(__FreeBSD__)
const int sig = SIGTERM;
procctl(P_PID, 0, PROC_PDEATHSIG_CTL, (void *)&sig);
if (getppid() == 1) /* parent already died before procctl */
flushAndExit(FDB_EXIT_SUCCESS);
#endif
if (opts.flowProcessName == "KeyValueStoreProcess") {