diff options
author | Pankaj Gupta <pagupta@redhat.com> | 2014-03-12 22:24:27 +0530 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2014-04-25 13:40:03 +0200 |
commit | 13a12f869bf2211c7039f9a601ac9e1076535663 (patch) | |
tree | 89601331da8c02629e46283952a43c7e6cde2bf6 /net/tap.c | |
parent | 0e96643c98eb22a5f2e11ac500852133032d38e4 (diff) |
tap: Avoid extra iterations while closing file fd
Avoid iterations for fd 0, 1 & 2 when we are closing file fds in child process.
Signed-off-by: Pankaj Gupta <pagupta@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'net/tap.c')
-rw-r--r-- | net/tap.c | 14 |
1 files changed, 4 insertions, 10 deletions
@@ -367,11 +367,8 @@ static int launch_script(const char *setup_script, const char *ifname, int fd) if (pid == 0) { int open_max = sysconf(_SC_OPEN_MAX), i; - for (i = 0; i < open_max; i++) { - if (i != STDIN_FILENO && - i != STDOUT_FILENO && - i != STDERR_FILENO && - i != fd) { + for (i = 3; i < open_max; i++) { + if (i != fd) { close(i); } } @@ -452,11 +449,8 @@ static int net_bridge_run_helper(const char *helper, const char *bridge) char br_buf[6+IFNAMSIZ] = {0}; char helper_cmd[PATH_MAX + sizeof(fd_buf) + sizeof(br_buf) + 15]; - for (i = 0; i < open_max; i++) { - if (i != STDIN_FILENO && - i != STDOUT_FILENO && - i != STDERR_FILENO && - i != sv[1]) { + for (i = 3; i < open_max; i++) { + if (i != sv[1]) { close(i); } } |