Hello, I have read the FAQ, and know that you can't fork with an open database connection. I'm not doing that. I am however very confused If anyone has the time to read this and give a hint as to what might be going on, it would be greatly appreciated.
Thanks, Kevin Martin --------------------------------------------------------------------------- Firstly, this is running on mac os x 10.5.8 with sqlite 3.7.7.1 compiled directly into all binaries. Here is the situation: parent process opens database does stuff closes database (sqlite3_close returns SQLITE_OK) creates pipe forks closes write end of pipe reopens database reads data from pipe until it closes continues on (all database queries issued here work) child (relevant code) global_ios->notify_fork(boost::asio::io_service::fork_child); signal(SIGHUP, SIG_IGN); setsid(); //close the socket, pipe, and stdin global_currentSocket.reset(); close(pipefd[0]); close(STDIN_FILENO); //send stdout and stderr to the pipe dup2(pipefd[1], STDERR_FILENO); dup2(pipefd[1], STDOUT_FILENO); close(pipefd[1]); execl(arguments) Now, in the execed child the database is opened and I can run queries and everything is fine until I do close(STDIN_FILENO); close(STDOUT_FILENO); close(STDERR_FILENO); open("/dev/null",O_RDONLY); open("/dev/null",O_WRONLY); open("/dev/null",O_WRONLY); After this point, any sqlite3_step() calls return SQLITE_ERROR. Although I have forgotten the exact details, there was some very similar code that consistently produced SQLITE_IOERR instead. If I close the database before I close stdout/stdin/stderr and reopen it afterwards there is no problem and everything works as expected. The thing I find really confusing is if I run the execed child directly from the shell instead of from the parent, there is no problem and everything works fine. Which makes me think I am doing something hideously wrong whilst forking. Any insight appreciated. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users