mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-29 16:44:29 +02:00
Implement an environment variable to keep Icinga from closing FDs on startup
fixes #12510
This commit is contained in:
parent
218e780a44
commit
53f5a603ce
@ -706,20 +706,22 @@ VOID WINAPI ServiceMain(DWORD argc, LPSTR *argv)
|
|||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
rlimit rl;
|
if (!getenv("ICINGA2_KEEP_FDS")) {
|
||||||
if (getrlimit(RLIMIT_NOFILE, &rl) >= 0) {
|
rlimit rl;
|
||||||
rlim_t maxfds = rl.rlim_max;
|
if (getrlimit(RLIMIT_NOFILE, &rl) >= 0) {
|
||||||
|
rlim_t maxfds = rl.rlim_max;
|
||||||
|
|
||||||
if (maxfds == RLIM_INFINITY)
|
if (maxfds == RLIM_INFINITY)
|
||||||
maxfds = 65536;
|
maxfds = 65536;
|
||||||
|
|
||||||
for (rlim_t i = 3; i < maxfds; i++) {
|
for (rlim_t i = 3; i < maxfds; i++) {
|
||||||
int rc = close(i);
|
int rc = close(i);
|
||||||
|
|
||||||
#ifdef I2_DEBUG
|
#ifdef I2_DEBUG
|
||||||
if (rc >= 0)
|
if (rc >= 0)
|
||||||
std::cerr << "Closed FD " << i << " which we inherited from our parent process." << std::endl;
|
std::cerr << "Closed FD " << i << " which we inherited from our parent process." << std::endl;
|
||||||
#endif /* I2_DEBUG */
|
#endif /* I2_DEBUG */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user