Factor out closing all file descriptors for later optimisation.

This commit is contained in:
Simon Kelley
2020-03-02 17:10:25 +00:00
parent c992ed4bef
commit 0541a1adf7
4 changed files with 19 additions and 16 deletions

View File

@@ -131,12 +131,8 @@ int create_helper(int event_fd, int err_fd, uid_t uid, gid_t gid, long max_fd)
Don't close err_fd, in case the lua-init fails.
Note that we have to do this before lua init
so we don't close any lua fds. */
for (max_fd--; max_fd >= 0; max_fd--)
if (max_fd != STDOUT_FILENO && max_fd != STDERR_FILENO &&
max_fd != STDIN_FILENO && max_fd != pipefd[0] &&
max_fd != event_fd && max_fd != err_fd)
close(max_fd);
close_fds(max_fd, pipefd[0], event_fd, err_fd);
#ifdef HAVE_LUASCRIPT
if (daemon->luascript)
{