Yes, tried that. No change in result.
Assuming sqlite does a |F_GETFD| then restores when done.
I built in some testing to see if the file descriptor was being mangled,
and cannot detect any difference.
Test:
flags = fcntl(fd[0], F_GETFL, 0);
char *cFlagMsg;
cFlagMsg=calloc(255,sizeof(char));
snprintf(cFlagMsg,255,"%s","FLAGS: ");
if (flags & O_NONBLOCK)
strcat(cFlagMsg,"O_NONBLOCK ");
if (flags & O_APPEND)
strcat(cFlagMsg,"O_APPEND ");
if (flags & O_DSYNC)
strcat(cFlagMsg,"O_DSYNC ");
if (flags & O_RSYNC)
strcat(cFlagMsg,"O_RSYNC ");
if (flags & O_SYNC)
strcat(cFlagMsg,"O_SYNC ");
Results:
// before change to O_NONBLOCK
GETFL Flags= 0
// after change to O_NONBLOCK
GETFL Flags= 2048
FLAGS: O_NONBLOCK
I inserted this code in place of my original calls to open and close:
sqlite3 *db;
char *zErrMsg = 0;
int rc;
rc = sqlite3_open("/etc/solarwave/aem.db", &db);
if( rc )
{
WriteSyslogMessage("Can't open database: %s\n",
sqlite3_errmsg(db));
sqlite3_close(db);
exit(1);
}
rc = sqlite3_exec(db, "SELECT * FROM dbsensors", NULL, 0, &zErrMsg);
if( rc!=SQLITE_OK )
{
WriteSyslogMessage("SQL error: %s\n", zErrMsg);
sqlite3_free(zErrMsg);
}
sqlite3_close(db);
(Note: WriteSyslogMessage() issued a system("logger 'string'"); call)
Same issue. -1 returned during read().
/m
D. Richard Hipp , On 8/11/2009 15:38:
> On Aug 11, 2009, at 2:53 PM, Mark Richards wrote:
>
>
>> Environment:
>> Linux axis 2.6.19 #9 PREEMPT Mon Apr 6 15:44:03 EDT 2009 cris
>> unknown
>>
>> Sqlite:
>> Sqlite: sqlite-3.6.14
>> ./configure --host=cris-axis-linux-gnu
>> --prefix=/AEMDEV/83+/devboard-R2_10/target/cris-axis-linux-gnu
>> --enable-static=yes --enable-shared=yes --disable-dynamic-extensions
>>
>> Application:
>> My application runs against the shared library built as above.
>>
>> Code in my application fails after calling sqlite3_open().
>>
>> This synopsis is of a function designed to spawn a shell, execute a
>> command, and read back the result via a pipe of stdout. It works
>> fine,
>> until sqlite3_open() is called anywhere PRIOR.
>>
>> prior sqlite3_open() call:
>> sqlite3 *dbf;
>> sqlite3_open("/path/to/my.db",&dbf);
>>
>>
>> fflush(stdout);
>> pipe(fd);
>> pid = fork();
>> if (pid == 0)
>> {
>> dup2(fd[1], STDOUT_FILENO);
>> dup2(fd[1], STDERR_FILENO);
>> close(fd[0]);
>>
> Have you tried called sqlite3_close() here to see if that helps? All
> of SQLite's file descriptors are FD_CLOEXEC, but who knows....
>
>
>> execl("/bin/sh", "sh", "-c", "echo 123", 0);
>> }
>> if (-1 == (flags = fcntl(fd[0], F_GETFL, 0)))
>> flags = 0;
>> fcntl(fd[0], F_SETFL, flags | O_NONBLOCK);
>>
>> .. within a loop:
>>
>> got=read(fd[0], buf, sizeof(buf));
>> if (got>-1)
>> {
>> snprintf(cValue,4,"%s",buf);
>> break;
>> }
>> // got ==-1
>>
> D. Richard Hipp
> [email protected]
>
>
>
> _______________________________________________
> sqlite-users mailing list
> [email protected]
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users