DATABASE NOT SELECTED error when exiting!
Posted in 1999
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL, Platform-Specific Issues
I am running Informix 5.10 on HP-UX 10.20. In one of my programs (esqlc daemon) after catching a "kill" signal the program calls a cleanup routine which updates some entries on some tables. This works most of the time. Sometimes after catching the "kill" signal the cleanup routine is called but it fails with "error 349" when it tries to update the tables. The error number translates to "DATABASE NOT SELECTED YET" message. I have tried selecting the database again at the very beginning of the cleanup routine using "DATABASE db_name" command, and still wound up with the same error. Can anyone help me figure this one out? Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't.
sdayalan@my-deja.com wrote: > > I am running Informix 5.10 on HP-UX 10.20. In one of my programs > (esqlc daemon) after catching a "kill" signal the program calls a > cleanup routine which updates some entries on some tables. This works > most of the time. Sometimes after catching the "kill" signal the cleanup > routine is called but it fails with "error 349" when it tries to update > the tables. The error number translates to "DATABASE NOT SELECTED YET" > message. I have tried selecting the database again at the very beginning > of the cleanup routine using "DATABASE db_name" command, and still wound > up with the same error. Can anyone help me figure this one out? The key is that this is OL 5.xx so your app has a child process, the sqlturbo process. When you send a signal to a process it's children also receive the same signal. The sqlturbo is getting the signal, I assume is it not a KILL since you are trapping it, but a SIGTERM, SIGQUIT, SIGPIPE, and some other signals as well, would cause the sqlturbo process to exit thereby disconnecting you from the database. What you have to do is to set the signal handling for the signal you want to use to SIG_IGN before opening the database at the beginning of the application, then when the sqlturbo starts up it will inherit that behavior. Once the database is open THEN you can reset the signal handling to point to your handler function. Since the handler function does not exist in the child even if you set the handler before opening the database the child will revert to default behavior, thus you need to do the SIG_IGN before and set up the handler after the DATABASE statement. Also in the handler it is best to call sqlexit() before the handler returns or calls exit() to make certain that the sqlturbo exits gracefully. Art S. Kagel
In article <37611FD1.4D34A682@bloomberg.net>, Art S. Kagel <kagel@bloomberg.net> writes >The key is that this is OL 5.xx so your app has a child process, the >sqlturbo process. When you send a signal to a process it's children >also receive the same signal. The sqlturbo is getting the signal, I >assume is it not a KILL since you are trapping it, but a SIGTERM, >SIGQUIT, SIGPIPE, and some other signals as well, would cause the >sqlturbo process to exit thereby disconnecting you from the database. >What you have to do is to set the signal handling for the signal you >want to use to SIG_IGN before opening the database at the beginning of >the application, then when the sqlturbo starts up it will inherit that >behavior. Once the database is open THEN you can reset the signal No! Check the FAQ about killing processes. SIG_PIPE and SIG_TERM are used internally by Informix.. You need to check why the sqlturbo is being sent these signals... > >Art S. Kagel -- David Williams
David Williams wrote: > > In article <37611FD1.4D34A682@bloomberg.net>, Art S. Kagel > <kagel@bloomberg.net> writes > >The key is that this is OL 5.xx so your app has a child process, the > >sqlturbo process. When you send a signal to a process it's children > >also receive the same signal. The sqlturbo is getting the signal, I > >assume is it not a KILL since you are trapping it, but a SIGTERM, > >SIGQUIT, SIGPIPE, and some other signals as well, would cause the > >sqlturbo process to exit thereby disconnecting you from the database. > >What you have to do is to set the signal handling for the signal you > >want to use to SIG_IGN before opening the database at the beginning of > >the application, then when the sqlturbo starts up it will inherit that > >behavior. Once the database is open THEN you can reset the signal > > No! Check the FAQ about killing processes. SIG_PIPE and SIG_TERM > are used internally by Informix.. You need to check why the sqlturbo > is being sent these signals... EXACTLY the point David. The SQLTURBO traps SIGPIPE to know if it has lost contact with a remote server and SIGTERM as one way it detects if it's parent has exited. By disabling the signal passing from parent to child before setting up SQLTURBO the sqlturbo process will not get these signals from its parent, which is OK it does not expect a SIGPIPE from it's parent and it does not need the SIGTERM detection to see the parent exit if you remember to CLOSE DATABASE or call sqlexit() from the app. In addition, the sqlturbo WILL still set up its own signal handling, which it would do anyway, so all will be well. I've done this for years and it solves the problem without adding new ones. Art S. Kagel