Re: 4GL Program Running In Background
Posted in 1999
glynb@bicceri.demon.co.uk wrote: > > We have a series of 4GL programs that are designed to be able to be run in > either foreground or background. When running in foreground, if a database > error is encountered, the program opens a window with a message to this > effect and reports the error to the program's log. However, if this same > program is being run in background (i.e. no terminal is attached) the attempt > to display the window (naturally) fails but the program execution fails to > terminate. The process then consumes process and engine time until other > user's complain about system response and we notice the error in the log file > then kill of the executable. Is there any way of a 4GL program detecting that > it is being run in background (regardless of whether the parent process is > still attached or not). If we were able to detect this we could have the > program call an error routine that does not attempt to write back to the > terminal. Well you've seen the answers involving an extra parameter. But if you really don't want to pass a parameter, then you could do something along the lines of: MAIN LET status = 0 RUN "tty >/dev/null 2>&1" RETURNING status IF status THEN DISPLAY "BACKGROUND" ELSE DISPLAY "FOREGROUND" END IF END MAIN Just be careful of RETURNING. I see it is a bit buggy in version 6.02 for instance. It just returned a NULL value which confused me for a while. :-) Hope that helps, -- Mark. +----------------------------------------------------------+-----------+ |Mark D. Stock - Informix SA http://www.informix.com |//////// /| |mailto:mdstock@informix.com http://www.informix.com/idn |///// / //| |http://www.iiug.org +-----------------------------------+//// / ///| | Tel: +27 11 807 0313 |If it's slow, the users complain. |/// / ////| | Fax: +27 838250 2325 |If it's fast, the users keep quiet.|// / /////| |Cell: +27 83 250 2325 |Therefore, "No news: travels fast"!|/ ////////| +----------------------+-----------------------------------+-----------+