Allow O_CLOEXEC to be used in dbopen() flags

There is also a small portability crutch, also present in NetBSD,
to allow compiling on a system that doesn't define O_CLOEXEC.

Approved by:	rpaulo (mentor)
Obtained from:	NetBSD (r1.17, r1.18)
Differential Revision:	https://reviews.freebsd.org/D5549
This commit is contained in:
Kurt Lidl 2016-03-06 04:38:08 +00:00
parent 13f28d969a
commit 06feb971e7

View File

@ -44,6 +44,10 @@ __FBSDID("$FreeBSD$");
static int __dberr(void);
#ifndef O_CLOEXEC
#define O_CLOEXEC 0
#endif
DB *
dbopen(const char *fname, int flags, int mode, DBTYPE type, const void *openinfo)
{
@ -51,7 +55,7 @@ dbopen(const char *fname, int flags, int mode, DBTYPE type, const void *openinfo
#define DB_FLAGS (DB_LOCK | DB_SHMEM | DB_TXN)
#define USE_OPEN_FLAGS \
(O_CREAT | O_EXCL | O_EXLOCK | O_NOFOLLOW | O_NONBLOCK | \
O_RDONLY | O_RDWR | O_SHLOCK | O_SYNC | O_TRUNC)
O_RDONLY | O_RDWR | O_SHLOCK | O_SYNC | O_TRUNC | O_CLOEXEC)
if ((flags & ~(USE_OPEN_FLAGS | DB_FLAGS)) == 0)
switch (type) {