Re: 4gl Program's Parent Dies, Child Continues
Posted in 1996
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
Paul J. Mantyla wrote: > > I've been unable to find a solution to this problem in the International > Informix User's Group FAQ. I'm hoping that this is a well-known problem > with a well-known solution. Yes, I think it's a well known problem. > We have a compiled 4gl program which runs another compiled 4gl program. > Both the parent process and the child process are interactive. If the parent > process is killed, it seems as if both the underlying shell (ksh) and the > child process try to claim the terminal, resulting in an unusable terminal. Sure, because the shell will try to continue and needs special terminal settings. The Korn Shell as well as the C-Shell are able to reset your terminal settings after a command exited. > If the shell process is killed, the child process continues. However it > has lost it's terminal and goes into and infinite loop, consuming 100% of > the cpu on the system. When you kill your login-shell with the signal 0, 1, 2 or 15, your login-shell will send all it's child processes a signal to terminate, unless the process didn't prevent this by starting a new process group ( setpgrp() ). But I think the process will loose it's control terminal and therefore the process must open it's own terminal. > Is their a special way to start child 4gl programs to prevent this sort of > behavior? (Through an external C function?) > I don't know if there is a special function. But what I know is that if you would send your child process two signals ( 1st SIGSTOP, 2nd SIGCONT ) this should work. The ksh and csh reset the terminal settings, because it is possible to stop a process. But when you stop a process that has changed the terminal settings, the shell must find a way to read data in cooked mode, instead of raw mode. Therefore the shell restores it's own settings. If you continue with processing the stopped process, this process has to restore it's settings. Normally the both signals are created by pressing <ctrl-z> ( SIGSTOP ) and the shell command "fg %1" ( will send SIGCONT to job 1 ). Because I don't know, whether Informix catches both signals, I would please you to send me a short reply. TIA, Stefan stefan@weideneder.de