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. The simple solution is a commandline option when explicitely starting it in the background and write a C routine to trap SIGSTOP and SIGTSTOP for when a users ^Zs a process to background it manually, though the latter can cause problems when the user wants it in the foreground again or stops it by accident and foregrounds it immediately. I do not know anyway to detect that you are in the background. HMMM there is some check on the tty that can be done it is what some programs do to avoid writing to the terminal in background mode altogether the suspend themselves instead. Look through Stevens' UNIX Network Programming I have a vague memory of seeing something there but no time to look now. Art S. Kagel