aboutsummaryrefslogtreecommitdiff
path: root/src/os_unix.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2013-08-30 14:24:12 +0000
committerdrh <drh@noemail.net>2013-08-30 14:24:12 +0000
commit77a3fdc1b063dd3775fa1da843d5cc404fdf3f1c (patch)
tree2ea0ca598ce4066751393ab51ba9dad55f8c2ba5 /src/os_unix.c
parent43398081a87710d1a83e3ca35d2e93fa8e5ce8f0 (diff)
downloadsqlite-77a3fdc1b063dd3775fa1da843d5cc404fdf3f1c.tar.gz
sqlite-77a3fdc1b063dd3775fa1da843d5cc404fdf3f1c.zip
Add the SQLITE_MINIMUM_FILE_DESCRIPTOR compile-time option, for control over
exactly which low-numbered file descriptors SQLite will use. FossilOrigin-Name: ba5190534330a25722eeb7ea9c42da7a6d146014
Diffstat (limited to 'src/os_unix.c')
-rw-r--r--src/os_unix.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index 8688a652f..797ace031 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -552,6 +552,15 @@ static const char *unixNextSystemCall(sqlite3_vfs *p, const char *zName){
}
/*
+** Do not accept any file descriptor less than this value, in order to avoid
+** opening database file using file descriptors that are commonly used for
+** standard input, output, and error.
+*/
+#ifndef SQLITE_MINIMUM_FILE_DESCRIPTOR
+# define SQLITE_MINIMUM_FILE_DESCRIPTOR 3
+#endif
+
+/*
** Invoke open(). Do so multiple times, until it either succeeds or
** fails for some reason other than EINTR.
**
@@ -581,7 +590,7 @@ static int robust_open(const char *z, int f, mode_t m){
if( errno==EINTR ) continue;
break;
}
- if( fd>2 ) break;
+ if( fd>=SQLITE_MINIMUM_FILE_DESCRIPTOR ) break;
osClose(fd);
sqlite3_log(SQLITE_WARNING,
"attempt to open \"%s\" as file descriptor %d", z, fd);