Skip to main content

Problem:

The only reason a process would continue to run when a terminal session is ended is when the terminal session is not shut down correctly, for example if a client machine is switched off unexpectadly or the network connection is lost.  

When a telnet session is 'killed' i.e. not shut down cleanly, it does not send any signal back to any child processes (cobol, C or vi for example) and therefore the child processes have no reason to die and they continue running.   

Resolution:

The best option is to always close the Cobol application cleanly.  The other option is to use the exec command so that the cobol process is not a child process.

When you don't use "exec" you effectively have two processes running, the first one is the shell invoked from the telnet session  the second is "cobrun xxxx". If you then switch off the PC or the connection is lost, only the shell is killed when the telnet session dies and the second process (cobrun or c or vi, etc ... ) remains alive and running.  

If you do use "exec" then you have only one process running, the first one "the shell invoked from the telnet session" is replaced by "cobrun xxxx" as soon as you invoke "exec cobrun xxxx".  

If the telnet session is then terminated unexptectedly "cobrun xxxx" is killed when the telnet session dies as this is the only process still associated to the telnet session.  If you use:

exec cobrun programname

to start your application then the process will be killed when the telnet session is ended.

Old KB# 7199