--- sqlite-3.7.2/sqlite3.c.bak 2010-08-24 02:01:05.000000000 +0300 +++ sqlite-3.7.2/sqlite3.c 2010-08-24 20:26:53.152192980 +0300 @@ -26862,10 +26862,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 OSTRACE(("OPENDIR %-3d %s\n", fd, zDirname)); @@ -27178,6 +27183,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 if( fd<0 ){ mode_t openMode; /* Permissions to create file with */ @@ -27238,7 +27246,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