1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-12 13:01:09 +03:00

Set FD_CLOEXEC on all open files under Unix. Ticket #2475. (CVS 4146)

FossilOrigin-Name: f1e5fed8eb0fb92bd0f040666c017850afe3cf9f
This commit is contained in:
drh
2007-06-29 12:04:26 +00:00
parent 6bd00bfda7
commit e78669b6b8
3 changed files with 17 additions and 10 deletions

View File

@@ -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);