Move some of the initialization code into icinga-app

refs #6257
This commit is contained in:
Gunnar Beutner 2015-02-20 19:57:26 +01:00
parent 9ae9204df2
commit 37e075c38a
2 changed files with 19 additions and 17 deletions

View File

@ -614,6 +614,25 @@ int main(int argc, char **argv)
/* must be called before using any other libbase functions */
Application::InitializeBase();
#ifndef _WIN32
rlimit rl;
if (getrlimit(RLIMIT_NOFILE, &rl) >= 0) {
rlim_t maxfds = rl.rlim_max;
if (maxfds == RLIM_INFINITY)
maxfds = 65536;
for (rlim_t i = 3; i < maxfds; i++) {
int rc = close(i);
#ifdef I2_DEBUG
if (rc >= 0)
std::cerr << "Closed FD " << i << " which we inherited from our parent process." << std::endl;
#endif /* I2_DEBUG */
}
}
#endif /* _WIN32 */
/* Set command-line arguments. */
Application::SetArgC(argc);
Application::SetArgV(argv);

View File

@ -120,23 +120,6 @@ void Application::Exit(int rc)
void Application::InitializeBase(void)
{
#ifndef _WIN32
rlimit rl;
if (getrlimit(RLIMIT_NOFILE, &rl) >= 0) {
rlim_t maxfds = rl.rlim_max;
if (maxfds == RLIM_INFINITY)
maxfds = 65536;
for (rlim_t i = 3; i < maxfds; i++) {
#ifdef I2_DEBUG
if (close(i) >= 0)
std::cerr << "Closed FD " << i << " which we inherited from our parent process." << std::endl;
#endif /* I2_DEBUG */
}
}
#endif /* _WIN32 */
#ifdef _WIN32
/* disable GUI-based error messages for LoadLibrary() */
SetErrorMode(SEM_FAILCRITICALERRORS);