src/agent/Watchdog/WatchdogMain.cpp in passenger-5.2.0 vs src/agent/Watchdog/WatchdogMain.cpp in passenger-5.2.1

- old
+ new

@@ -174,10 +174,11 @@ #include "CoreWatcher.cpp" /***** Functions *****/ +#if !BOOST_OS_MACOS static FILE * openOomAdjFileGetType(const char *mode, OomFileType &type) { FILE *f = fopen("/proc/self/oom_score_adj", mode); if (f == NULL) { f = fopen("/proc/self/oom_adj", mode); @@ -247,10 +248,11 @@ } fclose(f); return oldScore; } +#endif static void terminationHandler(int signo) { ssize_t ret = write(workingObjects->exitEvent.writerFd(), "x", 1); (void) ret; // Don't care about the result. @@ -789,11 +791,13 @@ * the system administrator will have to restart the web server for Phusion * Passenger to be usable again. So here we disable Linux's OOM killer * for this watchdog. Note that the OOM score is inherited by child processes * so we need to restore it after each fork(). */ +#if !BOOST_OS_MACOS string oldOomScore = setOomScoreNeverKill(); +#endif watchdogSchema = new Schema(); watchdogConfig = new ConfigKit::Store(*watchdogSchema); initializeAgent(argc, &argv, SHORT_PROGRAM_NAME " watchdog", *watchdogConfig, watchdogSchema->core.schema.loggingKit.translator, @@ -802,10 +806,12 @@ // Start all sub-agents with this environment variable. setenv("PASSENGER_USE_FEEDBACK_FD", "true", 1); wo = boost::make_shared<WorkingObjects>(); workingObjects = wo.get(); +#if !BOOST_OS_MACOS wo->extraConfigToPassToSubAgents["oom_score"] = oldOomScore; +#endif } static void maybeSetsid() { /* Become the session leader so that Apache can't kill the