Re: sqlturbo connection gets inherited
Posted in 1994
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
lester@access.digex.net (Lester Knutsen) writes: >Todd Saylor writes: >> I just learned something interesting about sqlturbo connections. Perhaps >> this is common knowledge somewhere, but it's new to me: When a process >> (an ESQL/C process, for example) begins talking to Informix, it spawns >> an sqlturbo process and opens a pipe to it. 2 file descriptors are used; >> one for reading and one for writing. Nothing exciting so far. >> >> Now, when the original process creates son processes for other reasons, >> they too inherit the open pipes. This can lead to orphaned sqlturbo >> processes if the parent exits/dies but the child remains. The orphaned >> sqlturbo, in this case, will go away when the child process goes away. >> To me, it seems dangerous that son processes begin life accidentally >> connected to an sqlturbo. This could lead to additional problems if >> the son tried to read/write these files. >Yes, it WILL lead to problems if many child process start using >the same sqlturbo. If the child process needs to deal with the >database it needs to start the sqlturbo. >> Has anybody else noticed this? Is there any simple solution? It would >> seem that Informix could set the "close on exec" flag for the pipe fd's, >> so that the open files would not be inherited. Perhaps there is some >> reason one would want them inherited, but I can't think of one. Yes, Informix should set close on exec for the pipes to sqlexec. But there is a way around this, how about when you are spawning kids: switch (pid = fork()) { /* Leave stdio fd's open, close the rest */ case 0: for (i=3; i < getdtablesize(); i++) close(i); rc = exec(...); ... ... -- Eric Pederson PacTel Corporation eric@nit.pactel.com 510-210-8890