/ Check-in [ba519053]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add the SQLITE_MINIMUM_FILE_DESCRIPTOR compile-time option, for control over exactly which low-numbered file descriptors SQLite will use.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ba5190534330a25722eeb7ea9c42da7a6d146014
User & Date: drh 2013-08-30 14:24:12
Context
2013-08-30
17:35
If the cost of two whereLoop objects is the same in every way except that one has fewer expected output rows than the other, then choose the one with fewer output rows. check-in: 79e458ef user: drh tags: trunk
14:24
Add the SQLITE_MINIMUM_FILE_DESCRIPTOR compile-time option, for control over exactly which low-numbered file descriptors SQLite will use. check-in: ba519053 user: drh tags: trunk
13:29
Add a test for fts4 unicode61 option remove_diacritics=0. check-in: 6bf7ae6f user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/os_unix.c.

   547    547     }
   548    548     for(i++; i<ArraySize(aSyscall); i++){
   549    549       if( aSyscall[i].pCurrent!=0 ) return aSyscall[i].zName;
   550    550     }
   551    551     return 0;
   552    552   }
   553    553   
          554  +/*
          555  +** Do not accept any file descriptor less than this value, in order to avoid
          556  +** opening database file using file descriptors that are commonly used for 
          557  +** standard input, output, and error.
          558  +*/
          559  +#ifndef SQLITE_MINIMUM_FILE_DESCRIPTOR
          560  +# define SQLITE_MINIMUM_FILE_DESCRIPTOR 3
          561  +#endif
          562  +
   554    563   /*
   555    564   ** Invoke open().  Do so multiple times, until it either succeeds or
   556    565   ** fails for some reason other than EINTR.
   557    566   **
   558    567   ** If the file creation mode "m" is 0 then set it to the default for
   559    568   ** SQLite.  The default is SQLITE_DEFAULT_FILE_PERMISSIONS (normally
   560    569   ** 0644) as modified by the system umask.  If m is not 0, then
................................................................................
   577    586   #else
   578    587       fd = osOpen(z,f,m2);
   579    588   #endif
   580    589       if( fd<0 ){
   581    590         if( errno==EINTR ) continue;
   582    591         break;
   583    592       }
   584         -    if( fd>2 ) break;
          593  +    if( fd>=SQLITE_MINIMUM_FILE_DESCRIPTOR ) break;
   585    594       osClose(fd);
   586    595       sqlite3_log(SQLITE_WARNING, 
   587    596                   "attempt to open \"%s\" as file descriptor %d", z, fd);
   588    597       fd = -1;
   589    598       if( osOpen("/dev/null", f, m)<0 ) break;
   590    599     }
   591    600     if( fd>=0 ){