db: Use O_CLOEXEC instead of separate fcntl() call.
This commit is contained in:
parent
595ab5638b
commit
89521d4108
@ -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);
|
||||
|
@ -862,10 +862,8 @@ open_temp(HTAB *hashp)
|
||||
/* Block signals; make sure file goes away at process exit. */
|
||||
(void)sigfillset(&set);
|
||||
(void)_sigprocmask(SIG_BLOCK, &set, &oset);
|
||||
if ((hashp->fp = mkstemp(path)) != -1) {
|
||||
if ((hashp->fp = mkostemp(path, O_CLOEXEC)) != -1)
|
||||
(void)unlink(path);
|
||||
(void)_fcntl(hashp->fp, F_SETFD, 1);
|
||||
}
|
||||
(void)_sigprocmask(SIG_SETMASK, &oset, (sigset_t *)NULL);
|
||||
return (hashp->fp != -1 ? 0 : -1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user