diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2016-02-21 16:09:23 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2016-02-21 16:09:23 -0500 |
commit | eb3af1b4ab071e7e3a1f01a3f62390f976592e06 (patch) | |
tree | 15151f17893e1390a49be8293e1418e47bed0502 | |
parent | 43b4eb6c4318de43b163a3b5cae152ad2620d124 (diff) | |
download | bfs-eb3af1b4ab071e7e3a1f01a3f62390f976592e06.tar.xz |
bftw: Use O_CLOEXEC.
-rw-r--r-- | bftw.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -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; |