Skip to content

Commit

Permalink
close_fds: fix close of external fds
Browse files Browse the repository at this point in the history
commit 0f092d5 introduced the
regression.

Closes: containers#240

Signed-off-by: Giuseppe Scrivano <[email protected]>
  • Loading branch information
giuseppe committed Feb 24, 2021
1 parent 7310bf1 commit d862266
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/close_fds.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ static void __attribute__((constructor)) init()
ssize_t size = 0;
DIR *d;

/* Store how many FDs were open before the Go runtime kicked in. */
d = opendir("/proc/self/fd");
if (!d)
return;
Expand Down Expand Up @@ -74,10 +73,8 @@ void close_other_fds()
{
int fd;

for (fd = 3; fd < open_files_max_fd; fd++) {
for (fd = 3; fd <= open_files_max_fd; fd++) {
if (open_files_set == NULL || FD_ISSET(fd % FD_SETSIZE, &(open_files_set[fd / FD_SETSIZE])))
if (fd == sync_pipe_fd || fd == attach_pipe_fd || fd == dev_null_r || fd == dev_null_w || fd == oom_cgroup_fd
|| fd == oom_event_fd)
close(fd);
close(fd);
}
}

0 comments on commit d862266

Please sign in to comment.