Skip to content

Commit

Permalink
Ensure we don't leak file descriptors to child processes
Browse files Browse the repository at this point in the history
fixes #8900
  • Loading branch information
gunnarbeutner committed Oct 4, 2016
1 parent fa5036e commit a7b0cb5
Show file tree
Hide file tree
Showing 5 changed files with 406 additions and 128 deletions.
1 change: 0 additions & 1 deletion doc/17-language-reference.md
Expand Up @@ -381,7 +381,6 @@ ObjectsPath |**Read-write.** Contains the path of the Icinga 2 objects f
PidPath |**Read-write.** Contains the path of the Icinga 2 PID file. Defaults to RunDir + "/icinga2/icinga2.pid".
Vars |**Read-write.** Contains a dictionary with global custom attributes. Not set by default.
NodeName |**Read-write.** Contains the cluster node name. Set to the local hostname by default.
UseVfork |**Read-write.** Whether to use vfork(). Only available on *NIX. Defaults to true.
EventEngine |**Read-write.** The name of the socket event engine, can be "poll" or "epoll". The epoll interface is only supported on Linux.
AttachDebugger |**Read-write.** Whether to attach a debugger when Icinga 2 crashes. Defaults to false.
RunAsUser |**Read-write.** Defines the user the Icinga 2 daemon is running as. Used in the `init.conf` configuration file.
Expand Down
3 changes: 1 addition & 2 deletions doc/20-development.md
Expand Up @@ -118,9 +118,8 @@ the duplicate import in your `~/.gdbinit` file.

Call GDB with the binary (`/usr/sbin/icinga2` is a wrapper script calling
`/usr/lib64/icinga2/sbin/icinga2` since 2.4) and all arguments and run it in foreground.
If VFork causes trouble, disable it inside the gdb run.

# gdb --args /usr/lib64/icinga2/sbin/icinga2 daemon -x debug -DUseVfork=0 --no-stack-rlimit
# gdb --args /usr/lib64/icinga2/sbin/icinga2 daemon -x debug --no-stack-rlimit

The exact path to the Icinga 2 binary differs on each distribution. On Ubuntu
it is installed into `/usr/lib/x86_64-linux-gnu/icinga2/sbin/icinga2` on 64-bit systems
Expand Down
10 changes: 3 additions & 7 deletions icinga-app/icinga.cpp
Expand Up @@ -31,6 +31,7 @@
#include "base/scriptglobal.hpp"
#include "base/context.hpp"
#include "base/console.hpp"
#include "base/process.hpp"
#include "config.h"
#include <boost/program_options.hpp>
#include <boost/tuple/tuple.hpp>
Expand Down Expand Up @@ -153,13 +154,6 @@ int Main(void)
Application::DeclareRunAsGroup(ICINGA_GROUP);
Application::DeclareConcurrency(boost::thread::hardware_concurrency());

if (!ScriptGlobal::Exists("UseVfork"))
#ifdef __APPLE__
ScriptGlobal::Set("UseVfork", false);
#else /* __APPLE__ */
ScriptGlobal::Set("UseVfork", true);
#endif /* __APPLE__ */

ScriptGlobal::Set("AttachDebugger", false);

ScriptGlobal::Set("PlatformKernel", Utility::GetPlatformKernel());
Expand Down Expand Up @@ -454,6 +448,8 @@ int Main(void)
}
}
}

Process::InitializeSpawnHelper();
#endif /* _WIN32 */

std::vector<std::string> args;
Expand Down

0 comments on commit a7b0cb5

Please sign in to comment.