[Xapian-tickets] [Xapian] #651: Avoid low fds

Xapian nobody at xapian.org
Wed Aug 6 07:19:02 BST 2014


#651: Avoid low fds
----------------------------------+-------------------
        Reporter:  olly           |      Owner:  olly
            Type:  enhancement    |     Status:  new
        Priority:  normal         |  Milestone:  1.3.3
       Component:  Backend-Brass  |    Version:
        Severity:  normal         |   Keywords:
      Blocked By:                 |   Blocking:
Operating System:  All            |
----------------------------------+-------------------
\
\
 I noticed that sqlite has SQLITE_MINIMUM_FILE_DESCRIPTOR and by default
 avoids using fds less than 3 in case something else in the same process
 tries to write to them, thinking output is going to stdout or stderr (e.g.
 a call to {{{write(2, ...)}}}):

 http://sqlite.org/compile.html#minimum_file_descriptor

 Elsewhere I read that this was apparently added in response to actual
 database corruption from such situations (I bet that was a pain to debug!)

 I think Xapian should definitely avoid at least fds 1 and 2 for writable
 handles, probably avoid fd 0 for reading, and perhaps just avoid anything
 < 3 for read or write like sqlite seems to.

 I'll note we already have special case code to handle the lock file being
 opened as a low fd on Unix, where we fork a child process and want to hook
 up its stdin and stdout to the parent.

 Marking for brass initially, but we should do this for all backends.
\
\
\

--
Ticket URL: <http://trac.xapian.org/ticket/651>
Xapian <http://xapian.org/>
Xapian



More information about the Xapian-tickets mailing list