aboutsummaryrefslogtreecommitdiff
path: root/src/os_unix.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2007-06-29 12:04:26 +0000
committerdrh <drh@noemail.net>2007-06-29 12:04:26 +0000
commite78669b6b832a6340d53afb34c1917192dd01eda (patch)
treec5ea76723c8cc7df6a4794237b8bec92d934d526 /src/os_unix.c
parent6bd00bfda7231158b52e3e03b9f1b2ce7945bf39 (diff)
downloadsqlite-e78669b6b832a6340d53afb34c1917192dd01eda.tar.gz
sqlite-e78669b6b832a6340d53afb34c1917192dd01eda.zip
Set FD_CLOEXEC on all open files under Unix. Ticket #2475. (CVS 4146)
FossilOrigin-Name: f1e5fed8eb0fb92bd0f040666c017850afe3cf9f
Diffstat (limited to 'src/os_unix.c')
-rw-r--r--src/os_unix.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index 0bb9feef0..cc8449f56 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -918,15 +918,19 @@ static int unixOpenDirectory(
OsFile *id,
const char *zDirname
){
+ int h;
unixFile *pFile = (unixFile*)id;
assert( pFile!=0 );
SET_THREADID(pFile);
assert( pFile->dirfd<0 );
- pFile->dirfd = open(zDirname, O_RDONLY|O_BINARY, 0);
- if( pFile->dirfd<0 ){
+ pFile->dirfd = h = open(zDirname, O_RDONLY|O_BINARY, 0);
+ if( h<0 ){
return SQLITE_CANTOPEN;
}
- OSTRACE3("OPENDIR %-3d %s\n", pFile->dirfd, zDirname);
+#ifdef FD_CLOEXEC
+ fcntl(h, F_SETFD, fcntl(h, F_GETFD, 0) | FD_CLOEXEC);
+#endif
+ OSTRACE3("OPENDIR %-3d %s\n", h, zDirname);
return SQLITE_OK;
}
@@ -2577,6 +2581,9 @@ static int allocateUnixFile(
unixFile f;
int rc;
+#ifdef FD_CLOEXEC
+ fcntl(h, F_SETFD, fcntl(h, F_GETFD, 0) | FD_CLOEXEC);
+#endif
memset(&f, 0, sizeof(f));
sqlite3OsEnterMutex();
rc = findLockInfo(h, &f.pLock, &f.pOpen);