Re: esql/c v5, sqlexec problem
Posted in 1995
Fleur, I believe you're on the right track. When the parent process executes fork() and exec(), the child inherits all of the parent's open file (and pipe) descriptors. This is what I meant by two processes sharing the same connection to the database. However, I didn't mean to imply that it would be a usable connection. Although they both have the same set of files open, only the parent process made the "legal" connection (correct shared memory entries, etc). I'm not suprised the child had SQL problems. It has a half open connection only neither it nor the engine knows it. The sqlexec process is probably sticking around as long as there is someone on the other end of its pipe. Since both your parent and child processes are on the pipe, they must both exit before the sqlexec goes away (<- a reasonable guess). Anyway, let me know how the close of the child's descriptors affects the situation. All theories sound good until practice disproves them. --Craig (craig@chemistry.utah.edu) } } This is why they suggested I try sqldetach() I think. In the } Informix-ESQL/C manual it states that sqldetach is not for use if the } forked process executes an exec, which my program does. Using sqldetach() } in the child however, makes the parent process id the id of my process } instead of the sqlexec process. This concerns me because I thought the } ppid was fixed at the fork and I don't know how Informix could changed the } parent process id of a process AFTER it's been forked & exec'ed. Maybe } there's just a system call I'm missing. } } Spurred by your comments I did two things: Forked the child, then } connected to the database. The parent's sqlexec did not hang. } Unfortunately this is not an option. My parent process is a GUI that } controls execution of the child processes and must always be connected. } } Then I tried connecting to the database, forking the child and having the } child try to do a database access without explicitly connecting to the } database.. It didn't work, so I doubt your statement that both process } are sharing a single connection to the database. } } Basically, I don't see why *any* process that is a child should know } anything about it's siblings, much less block waiting for their exit, } which is what Informix's sqlexec process is doing. I guess I will go read } Stevens and try to figure out what could be going on in terms of dup'ing } pipes and such. (Eureka! An *idea*!) Maybe I just need to close all file } descriptors in the child process... }