summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;