summaryrefslogtreecommitdiffstats
path: root/bftw.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2016-02-21 16:09:23 -0500
committerTavian Barnes <tavianator@tavianator.com>2016-02-21 16:09:23 -0500
commiteb3af1b4ab071e7e3a1f01a3f62390f976592e06 (patch)
tree15151f17893e1390a49be8293e1418e47bed0502 /bftw.c
parent43b4eb6c4318de43b163a3b5cae152ad2620d124 (diff)
downloadbfs-eb3af1b4ab071e7e3a1f01a3f62390f976592e06.tar.xz
bftw: Use O_CLOEXEC.
Diffstat (limited to 'bftw.c')
-rw-r--r--bftw.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/bftw.c b/bftw.c
index 7ad36a6..8c8d8b4 100644
--- a/bftw.c
+++ b/bftw.c
@@ -399,7 +399,7 @@ static DIR *dircache_entry_open(struct dircache *cache, struct dircache_entry *e
asdf = asdf->parent;
} while (asdf != base);
- int flags = O_DIRECTORY;
+ int flags = O_RDONLY | O_DIRECTORY | O_CLOEXEC;
int fd = openat(at_fd, at_path, flags);
if (fd < 0 && dircache_should_retry(cache, base)) {
@@ -417,10 +417,10 @@ static DIR *dircache_entry_open(struct dircache *cache, struct dircache_entry *e
// footprint significantly, while keeping the fd around for future
// openat() calls.
- fd = dup(entry->fd);
+ fd = fcntl(entry->fd, F_DUPFD_CLOEXEC, 0);
if (fd < 0 && dircache_should_retry(cache, entry)) {
- fd = dup(entry->fd);
+ fd = fcntl(entry->fd, F_DUPFD_CLOEXEC, 0);
}
if (fd < 0) {
return NULL;