--- sqlite-3.6.7/src/os_unix.c.bak 2008-12-11 14:58:36.000000000 +0200 +++ sqlite-3.6.7/src/os_unix.c 2008-12-25 20:28:46.015230184 +0200 @@ -3377,10 +3377,15 @@ static int openDirectory(const char *zFi sqlite3_snprintf(MAX_PATHNAME, zDirname, "%s", zFilename); for(ii=(int)strlen(zDirname); ii>=0 && 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); @@ -3559,6 +3564,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); @@ -3596,7 +3604,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