This commit is contained in:
alesapin 2019-01-22 19:28:05 +03:00
parent e026759443
commit 6053d1f235

View File

@ -793,20 +793,20 @@ void BaseDaemon::closeFDs()
proc_path.list(fds);
for (const auto & fd_str : fds)
{
long fd = DB::parse<long>(fd_str);
int fd = DB::parse<int>(fd_str);
if (fd > 2 && fd != signal_pipe.read_fd && fd != signal_pipe.write_fd)
::close(fd);
}
}
else
{
long max_fd = -1;
int max_fd = -1;
#ifdef _SC_OPEN_MAX
max_fd = sysconf(_SC_OPEN_MAX);
if (max_fd == -1)
#endif
max_fd = 256; /// bad fallback
for (long fd = 3; fd < max_fd; ++fd)
for (int fd = 3; fd < max_fd; ++fd)
if (fd != signal_pipe.read_fd && fd != signal_pipe.write_fd)
::close(fd);
}