]> granicus.if.org Git - icinga2/commitdiff
Implement an option to disable use of vfork().
authorGunnar Beutner <gunnar.beutner@netways.de>
Fri, 31 Jan 2014 07:44:00 +0000 (08:44 +0100)
committerGunnar Beutner <gunnar.beutner@netways.de>
Fri, 31 Jan 2014 07:44:00 +0000 (08:44 +0100)
Fixes #5583

doc/4.2-global-variables.md
lib/base/process-unix.cpp

index becc1de5e663975596a13b616e3c224b85f13b55..d550b87432833b3eb4c9bb7434923c5bf4b0fbe7 100644 (file)
@@ -17,3 +17,4 @@ IcingaEnableEventHandlers |**Read-write.** Whether event handlers are globally e
 IcingaEnableFlapping      |**Read-write.** Whether flap detection is globally enabled. Defaults to true.
 IcingaEnableChecks        |**Read-write.** Whether active checks are globally enabled. Defaults to true.
 IcingaEnablePerfdata      |**Read-write.** Whether performance data processing is globally enabled. Defaults to true.
+IcingaUseVfork            |**Read-write.** Whether to use vfork(). Only available on *NIX. Defaults to true.
index e4886ae12416e137ddead2143b6aa2ebd6524cce..15e7f6837916fb10b7ab138891e190370496e610 100644 (file)
@@ -23,6 +23,7 @@
 #include "base/objectlock.h"
 #include "base/logger_fwd.h"
 #include "base/utility.h"
+#include "base/scriptvariable.h"
 #include <boost/bind.hpp>
 #include <boost/make_shared.hpp>
 #include <boost/foreach.hpp>
@@ -107,7 +108,12 @@ ProcessResult Process::Run(void)
        m_ExtraEnvironment.reset();
 
 #ifdef HAVE_VFORK
-       m_Pid = vfork();
+       Value use_vfork = ScriptVariable::Get("IcingaUseVfork");
+
+       if (use_vfork.IsEmpty() || static_cast<bool>(use_vfork))
+               m_Pid = vfork();
+       else
+               m_Pid = fork();
 #else /* HAVE_VFORK */
        m_Pid = fork();
 #endif /* HAVE_VFORK */