Re: [sqlite] System function with Sqlite
Hi Kervin > 1. Try these extra gcc flags in your build... > "-Wall -Wconversion -Wshadow". Also try > renaming your database handle to something >more unique. I renamed my database handle to something more unique but this did not have any affect. I also tried the extra flags you mentioned but I got alot of errors and warnings during compilation. > 2. Have you tried 'strace' like someone else >suggested? I tried to use strace but I don't have it on my system and when I copied it in and ran it I received errors. Do I need to recompile this for my system or something? I am unsure how to run it correctly on my system. > 3. Strip all unnecessary includes. Check > your include directory order. Yes I have already tried and check this with no success, > 4. Try a 'ldd' on your binary and make sure > you have the libraries you expected. Yes I have also checked this and it is as it should be. Thanks Chris ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] System function with Sqlite
Hello Chris, It looks like you've been dealing with this for a while now. 1. Try these extra gcc flags in your build... "-Wall -Wconversion -Wshadow". Also try renaming your database handle to something more unique. 2. Have you tried 'strace' like someone else suggested? 3. Strip all unnecessary includes. Check your include directory order. 4. Try a 'ldd' on your binary and make sure you have the libraries you expected. I'd guess that you're most likely dealing with a path issue ( runtime or compile time, library or maybe include ) I hope that helps. Best regards, Kervin - Original Message > From: Chris Brown <[EMAIL PROTECTED]> > To: General Discussion of SQLite Database > Sent: Monday, August 18, 2008 7:06:15 AM > Subject: Re: [sqlite] System function with Sqlite > > I have tried to trace the problem further through the Sqlite source by > checking at which point I could no-longer successfully call the system > function. I got as far as xOpen through sqlite3_open > opendatabase > > sqlite3Btreefactory > sqlite3Btreeopen > sqlite3PagerOpen > Sqlite3OsOpen > > xOpen. Immediately prior to the xOpen call I could successfully make System > calls but not after. > > I'm not sure if this additional information may be of help. > > Thanks > Chris > > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] System function with Sqlite
I have tried to trace the problem further through the Sqlite source by checking at which point I could no-longer successfully call the system function. I got as far as xOpen through sqlite3_open > opendatabase > sqlite3Btreefactory > sqlite3Btreeopen > sqlite3PagerOpen > Sqlite3OsOpen > xOpen. Immediately prior to the xOpen call I could successfully make System calls but not after. I'm not sure if this additional information may be of help. Thanks Chris ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] System function with Sqlite
Hi Chris > Can you check which libc you are using and if there is any LD_PRELOAD > or similar active? There does not appear to be any LD_PRELOAD active. The version of lic is 2.2.3. Thanks Chris ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] System function with Sqlite
Hi Asif > AFAIK, how the system() passes the command-string to the command-processor > is implementation defined. I would suggest that you also pass the shell > (e.g. /bin/sh) to system() in addition to the command string. Which shell > are you using? I am running bash version 2.05a.0(1). I tried passing the shell in addition to the command string as you suggested but the result was the same. Thanks Chris ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] System function with Sqlite
Hi Chris, On 8/15/08, Chris Brown <[EMAIL PROTECTED]> wrote: > > Can you offer any further help/suggestions? > AFAIK, how the system() passes the command-string to the command-processor is implementation defined. I would suggest that you also pass the shell (e.g. /bin/sh) to system() in addition to the command string. Which shell are you using? - Asif ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] System function with Sqlite
Thanks for your continued help Chris > As someone else suggest strace might be useful, build your application > as a binary and run it under strace: > > strace -f -o trace.txt ./name/of/your/thang I do not seem to have strace on my system. I am running Linux version 2.4.17_mv_121-malta-mips_fp_le with gcc version 2.95.3. I attempted to download and run strace but I couldn't get it to run correctly. > Can you check which libc you are using and if there is any LD_PRELOAD > or similar active? I'm sorry but how do I check this? > Some code does something like: > >for (fd = 2; fd <= 255; ++fd) >fcntl(fd, F_SETFD, FD_CLOEXEC); > I attempted to implement this but it did not appear to have any affect. Either that or I haven't implemented it correctly. Can you offer any further help/suggestions? Thanks Chris ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] System function with Sqlite
On Thu, Aug 14, 2008 at 04:37:48PM +1200, Chris Brown wrote: > After SQLite: [... odd output ...] > pipe:[120]fd1 ?g?T 1?? 2 04:54:50 CST 2008 > 6 > pipe:[120]fd1 ?g?T 1?? 2 04:54:50 CST 2008 [BTW; Your email is encoded in a very odd way and looks quite strange to me (others might have more luck).] Having those pipes seems odd. I assume sqlite closes everthing. As someone else suggest strace might be useful, build your application as a binary and run it under strace: strace -f -o trace.txt ./name/of/your/thang and put trace.txt somewhere for examination. I'm wondering if some library call(s) are doing something unexpected here. Can you check which libc you are using and if there is any LD_PRELOAD or similar active? > I am still relatively new to Linux so some of the commands you > mentioned are unfamiliar to me. I hope this output is what you > wanted. Could you explain how I can set FD_CLOEXEC? If its > unreliable then I really can't use it permanently but it may be a > useful test to run. Some code does something like: for (fd = 2; fd <= 255; ++fd) fcntl(fd, F_SETFD, FD_CLOEXEC); FD_CLOEXEC means that the file descriptors are closed on exec (otherwise they are 'inherited'). The reason I say it's not reliable is that you can have thousands (millions perhaps) of file descriptors so marking them all is cumbersome. It's better to fix the cause of the problem. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] System function with Sqlite
On Thu, Aug 14, 2008 at 10:59:57AM +1200, Chris Brown wrote: > Then this after sqlite3_close but before the second call to system: > > . > .. > 0 > 1 > 2 > 3 > 5 > 6 that seems wrong, for those which are symlinks (ie. 0->6) can you also readlink and print that out too please? it seems like some fd's are beinh held open as a work around you can loop over these fd's (say 2 though 255) and set FD_CLOEXEC (lots of things do this, it's a but of a hack and not entirely reliable) ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] System function with Sqlite
> that seems wrong, for those which are symlinks (ie. 0->6) can you also > readlink and print that out too please? > > it seems like some fd's are beinh held open > > as a work around you can loop over these fd's (say 2 though 255) and > set FD_CLOEXEC (lots of things do this, it's a but of a hack and not > entirely reliable) I repeated the test and ran readlink for each fd as you suggested. Here are the results before SQLite: . .. 0 /dev/console1 ¶g¤T 1¤ë 2 04:54:50 CST 2008 1 /dev/console1 ¶g¤T 1¤ë 2 04:54:50 CST 2008 2 /dev/console1 ¶g¤T 1¤ë 2 04:54:50 CST 2008 3 /proc/130/fd1 ¶g¤T 1¤ë 2 04:54:50 CST 2008 After SQLite: . /proc/130/fd1 ¶g¤T 1¤ë 2 04:54:50 CST 2008 .. /proc/130/fd1 ¶g¤T 1¤ë 2 04:54:50 CST 2008 0 /dev/console1 ¶g¤T 1¤ë 2 04:54:50 CST 2008 1 /dev/console1 ¶g¤T 1¤ë 2 04:54:50 CST 2008 2 /dev/console1 ¶g¤T 1¤ë 2 04:54:50 CST 2008 3 /proc/130/fd1 ¶g¤T 1¤ë 2 04:54:50 CST 2008 5 pipe:[120]fd1 ¶g¤T 1¤ë 2 04:54:50 CST 2008 6 pipe:[120]fd1 ¶g¤T 1¤ë 2 04:54:50 CST 2008 I am still relatively new to Linux so some of the commands you mentioned are unfamiliar to me. I hope this output is what you wanted. Could you explain how I can set FD_CLOEXEC? If its unreliable then I really can't use it permanently but it may be a useful test to run. Thanks Chris ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] System function with Sqlite
Again, for what it's worth: I'm using gcc 4.1.3 and I've successfully run this as myself, using sudo, and as root. While I realize we're not talking Windoze, have you tried rebooting, recompling, and rerunning it? > Hi Peter- Yes I'm running the code as you've put above and I used the full > source tree also. Its quite frustrating as to why I'm getting this strange > behaviour on my system. I accept that Sqlite may not be directly responsible > but the act of running it on my system is having an affect for some reason. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] System function with Sqlite
What does strace reveal? -- -- Stevie-O Real programmers use COPY CON PROGRAM.EXE ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] System function with Sqlite
> #include "sqlite3.h" > > main(int argc, char **argv) > { > static sqlite3 *db; > > system("whoami"); > sqlite3_open("junk.dbs", &db); > sqlite3_close(db); > system("whoami"); > } > > Works fine on mine, Chris. FWIW I did use the full source tree (the > .tar.gz file) for compilation and install of sqlite3.5.9 > Hi Peter- Yes I'm running the code as you've put above and I used the full source tree also. Its quite frustrating as to why I'm getting this strange behaviour on my system. I accept that Sqlite may not be directly responsible but the act of running it on my system is having an affect for some reason. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] System function with Sqlite
> before the system calls can you make a fucntion that does a > open/readdir of /proc/self/fd/ and prints the results (to compare > before and after)? Hi Chris- I did as you suggested and I had the following returned before sqlite3_openis called: . .. 0 1 2 3 Then this after sqlite3_close but before the second call to system: . .. 0 1 2 3 5 6 Thanks Chris ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] System function with Sqlite
#include "sqlite3.h" main(int argc, char **argv) { static sqlite3 *db; system("whoami"); sqlite3_open("junk.dbs", &db); sqlite3_close(db); system("whoami"); } Works fine on mine, Chris. FWIW I did use the full source tree (the .tar.gz file) for compilation and install of sqlite3.5.9 Chris Brown wrote: >> The "fossil" configuration management system (used to control the >> documentation of SQLite - see http://www.fossil-scm.org/ for details >> and http://www.sqlite.org/docsrc/timeline for an example) calls >> system() after sqlite3_open() in multiple places and it works just >> fine on Linux, OSX, various other flavors of unix, and even win32. >> Are you sure that SQLite is to blame here? > > No I couldn't be 100% certain that SQLite is to blame but I have stripped > out all other code to do the following and it hangs on the second system > call: > > system("whoami"); > sqlite3_open("/bin/test/testdb", &db); > sqlite3_close(db); > system("whoami"); > > I have checked the return value of sqlite3_open and it is zero. If I remove > the calls to sqlite3_open and sqlite3_close then both system calls complete > correctly. > > I also tried Peter's suggestion but that didn't have any affect either. > > Chris > > > > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] System function with Sqlite
On Wed, Aug 13, 2008 at 05:08:26PM +1200, Chris Brown wrote: > At the moment I can replicate this issue simply by having the code > sample in my previous post inside my main function with the sqlite > database variable declaration and thats it. before the system calls can you make a fucntion that does a open/readdir of /proc/self/fd/ and prints the results (to compare before and after)? ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] System function with Sqlite
> Are you closing standard output or standard input? No i'm not closing either. At the moment I can replicate this issue simply by having the code sample in my previous post inside my main function with the sqlite database variable declaration and thats it. If I assign the result of the second system call to a variable and interrupt it using ctrl-c it returns 2. Thanks Chris ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] System function with Sqlite
Chris Brown wrote: >>The "fossil" configuration management system (used to control the >>documentation of SQLite - see http://www.fossil-scm.org/ for details >>and http://www.sqlite.org/docsrc/timeline for an example) calls >>system() after sqlite3_open() in multiple places and it works just >>fine on Linux, OSX, various other flavors of unix, and even win32. >>Are you sure that SQLite is to blame here? > > > No I couldn't be 100% certain that SQLite is to blame but I have stripped > out all other code to do the following and it hangs on the second system > call: > > system("whoami"); > sqlite3_open("/bin/test/testdb", &db); > sqlite3_close(db); > system("whoami"); > > I have checked the return value of sqlite3_open and it is zero. If I remove > the calls to sqlite3_open and sqlite3_close then both system calls complete > correctly. > > I also tried Peter's suggestion but that didn't have any affect either. > > Chris > Are you closing standard output or standard input? ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] System function with Sqlite
> The "fossil" configuration management system (used to control the > documentation of SQLite - see http://www.fossil-scm.org/ for details > and http://www.sqlite.org/docsrc/timeline for an example) calls > system() after sqlite3_open() in multiple places and it works just > fine on Linux, OSX, various other flavors of unix, and even win32. > Are you sure that SQLite is to blame here? No I couldn't be 100% certain that SQLite is to blame but I have stripped out all other code to do the following and it hangs on the second system call: system("whoami"); sqlite3_open("/bin/test/testdb", &db); sqlite3_close(db); system("whoami"); I have checked the return value of sqlite3_open and it is zero. If I remove the calls to sqlite3_open and sqlite3_close then both system calls complete correctly. I also tried Peter's suggestion but that didn't have any affect either. Chris ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] System function with Sqlite
On Aug 12, 2008, at 10:09 PM, Chris Brown wrote: > Hi all > > I have an application written in C using Sqlite 3.5.9 on MontaVista > Linux. > > I am required to call the 'system()' function from within my code to > run external programs. Under normal circumstances this works without > problems. However as soon as I have used Sqlite from within my code > I am unable to successfully call the 'system()' function at any > point after that- the function will hang indefinitely without > returning a result. This will happen even if I am just calling > 'sqlite3_open' and 'sqlite3_close' to open and close a database. I > am not using Sqlite from the command line. I am currently running as > root. > > Can anyone offer any suggestions as to why this might be? The "fossil" configuration management system (used to control the documentation of SQLite - see http://www.fossil-scm.org/ for details and http://www.sqlite.org/docsrc/timeline for an example) calls system() after sqlite3_open() in multiple places and it works just fine on Linux, OSX, various other flavors of unix, and even win32. Are you sure that SQLite is to blame here? D. Richard Hipp [EMAIL PROTECTED] ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] System function with Sqlite
int main(int argc, char **argv) { int i; system("rm ppi.dbs ; sqlite3 ppi.dbs \".read ppi_create.sql\""); wait(NULL); /* open the database */ db_connect(); /* which calls sqlite3_open() */ system("echo what?"); wait(NULL); . . . } Works for me using Sqlite3.5.9. Ubuntu 7.10 on Intel. Chris Brown wrote: > Hi all > > I have an application written in C using Sqlite 3.5.9 on MontaVista Linux. > > I am required to call the 'system()' function from within my code to run > external programs. Under normal circumstances this works without problems. > However as soon as I have used Sqlite from within my code I am unable to > successfully call the 'system()' function at any point after that- the > function will hang indefinitely without returning a result. This will happen > even if I am just calling 'sqlite3_open' and 'sqlite3_close' to open and > close a database. I am not using Sqlite from the command line. I am currently > running as root. > > Can anyone offer any suggestions as to why this might be? > > Thanks Chris > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] System function with Sqlite
Hi all I have an application written in C using Sqlite 3.5.9 on MontaVista Linux. I am required to call the 'system()' function from within my code to run external programs. Under normal circumstances this works without problems. However as soon as I have used Sqlite from within my code I am unable to successfully call the 'system()' function at any point after that- the function will hang indefinitely without returning a result. This will happen even if I am just calling 'sqlite3_open' and 'sqlite3_close' to open and close a database. I am not using Sqlite from the command line. I am currently running as root. Can anyone offer any suggestions as to why this might be? Thanks Chris ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users