--- Andy Spencer <[EMAIL PROTECTED]> wrote:
> On Tue, 9 Oct 2007, Joe Wilson wrote:
> > --- Cyrus Durgin <[EMAIL PROTECTED]> wrote:
> > > i'm wondering if there's a "standard" way to get an open file handle from 
> > > an
> > > sqlite3 pointer using the C API.  anyone know?
> > 
> > No such function exists, but it would be a useful addition to the API.
> > Copying the database during an exclusive lock without spawning a process 
> > for instance...
> I agree.
> At Schrodinger, we added two functions to our version of sqlite3:
> /* The sqlite3 APIs to get file descriptors fo the open files */
> int sqlite3_get_database_file_fd( sqlite3* sqlite3_db_ptr );
> int sqlite3_get_journal_file_fd( sqlite3* sqlite3_db_ptr );

Do your functions always just return the fd of the first database "main"?

> This was done to prevent the open files from being inherited
> by forked child processes, using fcntl(fd, F_SETFD, FD_CLOEXEC),
> since otherwise those child processes could keep the files open,
> thereby preventing deletion of the database files (and the directory
> that contains them) in the parent process.

SQLite3 now has this code in os_unix.c:

  fcntl(h, F_SETFD, fcntl(h, F_GETFD, 0) | FD_CLOEXEC);

Is that your only use for requiring the file descriptor?

Another way is to pre-fork() one or more worker processes
before any sockets, files or database connections are made.
These pre-forked processes could take instructions from their 
parent and return information via a pipe(). Of course each 
worker process would have to re-open() all its own resources.

Check out the hottest 2008 models today at Yahoo! Autos.

To unsubscribe, send email to [EMAIL PROTECTED]

Reply via email to