home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!oracle!pyramid!infmx!davek
- From: davek@informix.com (David Kosenko)
- Newsgroups: comp.databases.informix
- Subject: Re: ESQL/C -- sqlturbo and sqlexit()
- Message-ID: <1993Jan27.153410.16789@informix.com>
- Date: 27 Jan 93 15:34:10 GMT
- References: <FORNEY.93Jan19085549@vega.bsdsun> <1993Jan21.090631.17764@pyra.co.uk> <C1Horv.1MH@nit.pactel.com>
- Sender: news@informix.com (Usenet News)
- Organization: Informix Software, Inc.
- Lines: 55
-
- Eric Pederson writes:
- >It seems that sqlexit() in ESQL/C version 4.x is doing a blocking
- >wait() instead of a waitpid() or a non-blocking wait3() or wait4().
- >If I want to sqlexit() before my other children have died, then the sqlexit()
- >hangs. Also, while it is hanging, I do a "ps" and find that sqlturbo is
- >*still* running. Isn't it supposed to wait() *after* the kill? If (while it
- >is hanging) I kill my application with a SEGV signal, I get the following in
- >an "adb" traceback:
- >
- >_wait4(?)
- >__DYNAMIC(0xefffe22c,0x0,0x2a9400,0x2,0x10,0x0) + 4
- >_killbackend(0x5035,0x0,0x0,0x10,0x2b2a68,0xc) + 34
- >_sqlexit(0x1,0x1f,0xefffe318,0x2c38d0,0xef7ea760,0x1) + 4
- >
- >Is this fixed in version 5.0 or is there a way around using sqlexit()
- >to stop the sqlturbo process when you are finished with ESQL?
-
- Well, let's take a look at what sqlexit() actually does. This is based
- on 5.0 behavior, though I don't think it changed from 4.x.
-
- As you can see from the stack trace, sqlexit() calls killbackend(); in fact,
- it does little else. killbackend() does all the work. What it does is to
- close the input and output pipe that is used to communicate with the server.
- It then does a wait() until the pid returned is that of the spawned server.
- This wait is done inside a while loop, which will not terminate until that
- child process has died. Note that there is no kill involved.
-
- On the server end, closing the pipes from the client end should generate either
- an eof from the read side (when the server reads from the pipe to see what to
- do next - this is a blocked read), or a SIGPIPE when it tries to write to a
- pipe whose other end is closed. The first case should be straightforward;
- the second can be problemmatic.
-
- The SIGPIPE generated by the write to the pipe can only occur when a write
- is initiated by the server. If you should attempt to perform an sqlexit()
- while the server is off doing some work (by catching a SIGINT in your app,
- and calling sqlexit() as part of your signal handler) you could wind up in
- some trouble, because the server is merrily off doing its work, and will
- not notice the closed pipes until it attempts to send something back. If
- it is involved in a complex operation (or the OnLine system is hung for
- one reason or another), the write will not be happening right away, and your
- app will be sitting on that wait until the server finishes what it is doing.
-
- The best way around this is to always start any signal handling with an
- sqlbreak(). That will interrupt the server asap, at which point it can see
- the sqlexit() stuff and clean up properly.
-
-
-
- Dave
- --
- Disclaimer: These opinions are not those of Informix Software, Inc.
- **************************************************************************
- "I look back with some satisfaction on what an idiot I was when I was 25,
- but when I do that, I'm assuming I'm no longer an idiot." - Andy Rooney
-