--- sqlite-3.6.13/sqlite3.c.bak 2009-04-20 11:39:22.215146871 +0300 +++ sqlite-3.6.13/sqlite3.c 2009-04-20 11:42:44.385145350 +0300 @@ -24283,10 +24283,15 @@ static int openDirectory(const char *zFi sqlite3_snprintf(MAX_PATHNAME, zDirname, "%s", zFilename); for(ii=(int)strlen(zDirname); ii>1 && zDirname[ii]!='/'; ii--); if( ii>0 ){ + int oflags = O_RDONLY | O_BINARY; + +#ifdef O_CLOEXEC + oflags |= O_CLOEXEC; +#endif zDirname[ii] = '\0'; - fd = open(zDirname, O_RDONLY|O_BINARY, 0); + fd = open(zDirname, oflags, 0); if( fd>=0 ){ -#ifdef FD_CLOEXEC +#if defined(FD_CLOEXEC) && !defined(O_CLOEXEC) fcntl(fd, F_SETFD, fcntl(fd, F_GETFD, 0) | FD_CLOEXEC); #endif OSTRACE3("OPENDIR %-3d %s\n", fd, zDirname); @@ -24465,7 +24470,9 @@ static int unixOpen( if( isCreate ) openFlags |= O_CREAT; if( isExclusive ) openFlags |= (O_EXCL|O_NOFOLLOW); openFlags |= (O_LARGEFILE|O_BINARY); - +#ifdef O_CLOEXEC + openFlags |= O_CLOEXEC; +#endif fd = open(zName, openFlags, isDelete?0600:SQLITE_DEFAULT_FILE_PERMISSIONS); OSTRACE4("OPENX %-3d %s 0%o\n", fd, zName, openFlags); if( fd<0 && errno!=EISDIR && isReadWrite && !isExclusive ){ @@ -24508,7 +24515,7 @@ static int unixOpen( } } -#ifdef FD_CLOEXEC +#if defined(FD_CLOEXEC) && !defined(O_CLOEXEC) fcntl(fd, F_SETFD, fcntl(fd, F_GETFD, 0) | FD_CLOEXEC); #endif