diff options
author | jilles <jilles@FreeBSD.org> | 2013-08-13 19:20:50 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2013-08-13 19:20:50 +0000 |
commit | 9381206c83fd21139368e4421be5d9b0c3d16bab (patch) | |
tree | cca8eb84544ed7fe9bcf47c517ae4a746a89f857 /lib/libc/db/btree | |
parent | cf48481217da0cd44a453cc420f3f74cd4820b24 (diff) | |
download | FreeBSD-src-9381206c83fd21139368e4421be5d9b0c3d16bab.zip FreeBSD-src-9381206c83fd21139368e4421be5d9b0c3d16bab.tar.gz |
db: Use O_CLOEXEC instead of separate fcntl() call.
Diffstat (limited to 'lib/libc/db/btree')
-rw-r--r-- | lib/libc/db/btree/bt_open.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/lib/libc/db/btree/bt_open.c b/lib/libc/db/btree/bt_open.c index 47f3646..94ba014 100644 --- a/lib/libc/db/btree/bt_open.c +++ b/lib/libc/db/btree/bt_open.c @@ -196,7 +196,7 @@ __bt_open(const char *fname, int flags, int mode, const BTREEINFO *openinfo, int goto einval; } - if ((t->bt_fd = _open(fname, flags, mode)) < 0) + if ((t->bt_fd = _open(fname, flags | O_CLOEXEC, mode)) < 0) goto err; } else { @@ -207,9 +207,6 @@ __bt_open(const char *fname, int flags, int mode, const BTREEINFO *openinfo, int F_SET(t, B_INMEM); } - if (_fcntl(t->bt_fd, F_SETFD, 1) == -1) - goto err; - if (_fstat(t->bt_fd, &sb)) goto err; if (sb.st_size) { @@ -405,7 +402,7 @@ tmp(void) (void)sigfillset(&set); (void)_sigprocmask(SIG_BLOCK, &set, &oset); - if ((fd = mkstemp(path)) != -1) + if ((fd = mkostemp(path, O_CLOEXEC)) != -1) (void)unlink(path); (void)_sigprocmask(SIG_SETMASK, &oset, NULL); return(fd); |