Re: Is it possible to timeout 4GL?
Posted in 1994
alan@po.den.mmc.com (Alan Popiel) writes: >->: ->John Powell (jpowell@cv.hp.com) originally wrote: >->: -> >->: ->Hello, >->: -> We are looking for a way to timeout 4GL programs when there is no terminal >->: ->response after n minutes. The problem we are having is as follows: >... >->:Alan Popiel (alan@po.den.mmc.com) answered: >->: There is no way to do this completely within 4GL. I have done something >->: similar thru the use of C subroutines called from 4GL. >->: >->: If you want to converse off-line, I can tell you some of the things I have >->: done in a Sun-OS environment that come close to what you want. While I >->: can't say for certain, I would assume that similar capabilities are >->: available under HPUX. >->Richard Spitz (spitz@GANS2X.ana.med.uni-muenchen.de) then requested: >-> >->Hi Alan, >-> >->could you please converse on-line in this group? I am also very interested >->in solutions to the timeout problem. >-> >->Regards, Richard >Alan Popiel (alan@po.den.mmc.com) answered: >At the request of my friend Richard, I will offer what I have to the group >at large. I suggested going off-line because the few answers I have only >partially address the problem as stated. Even so, my anwsers are somewhat >long. >1. To paraphrase Jonathan Leffler's answer to a similar question: The reason >you can't do this completely within 4GL is that 4GL only does one thing at a >time. If your 4GL program is waiting for input, it is just WAITING; it cannot >simultaneously be counting down a timer to accomplish the timeout. [ ... ] (source code deletes) >3. To handle time-out, I suggess the following approach. Warning: I have >NOT tried this in Unix, but it seems like it should work. (This is why I >did not broadcast this originally!) However, I have done this under the >Gould OS, which is similar to Unix. [ ... ] (suggestion removed) >Regards, >Alan ___________________________ We have used a similar approach for some time, with moderate success. Here is how we do this: We link in a subroutine written i C that first establish a signal handler for SIGALRM and then calls alarm(2). Then we periodically call it when we want to establish timeouts. We use set_alarm(0) before any queries that might take long time, to disable the alarm when the queries executes. Here is the subroutine: /* alarm_break is a routine to exit gracefully */ extern void alarm_break(); int set_alarm(nargs) int nargs; { int ant_sec; popint(&ant_sec); signal(SIGALRM, alarm_break); alarm(ant_sec); retint(0); return(1); } This has the benefit of not using an extra process, and being relatively simple to set up. Of course, we could check some more things in the alarm handler, like last modification time on the tty device, check if the sqlturbo in the same process group is using CPU time, etc. However, this does not to work when the user is in a ring menu. It seems like 4GL is setting up their own alarm handler, or they are blocking all/some signals (as interrupt does not work either). Any suggestions/comments on this ? We have tried this on the following platforms: Texas Instruments 1500's running TI Sys V 3.3.1, compiled 4GL 4.00 UH1 and compiled 4GL 4.10 UD1, 4GL RDS 4.00.UH1, HP 9000/800 running HP-UX 9.01, compiled 4GL 4.11.UC1, SUN/Sparc running SunOS 4.1.1, 4GL RDS 4.00.UC1 Thanks in advance, -- Oeyvind Gjerstad Systems dept Tollpost-Globe AS N-6301 Aandalsnes/Norway E-mail: ogj@tglobe2.tollpost.no Phone: (+47) 7122 6663 Fax: (+47) 7122 6694