From: rodkey@westmont.EDU (John Rodkey)
Newsgroups: comp.unix.aix
Subject: Question: What happens when a Terminal is powered-down?
Summary: AIX 3.1.6 - how does it handle powering off a terminal on a NTS?
Keywords: aix sigterm runaway pseudoterminals dynix UniVerse powerdown
Date: 11 Nov 92 23:24:12 GMT
Organization: Westmont College, Santa Barbara, CA


I have this setup:  RS/6000 mod 530, AIX 3.1.6, UniVerse 5.4, DYNIX v. 1??
Access to the RS/6000 from terminals is through Emulex and Lantronix 
Network terminal servers.  This problem occurs on both, so I have made
the assumption that the NTSs are not the weak link.

The terminals (wyse 50's, PCs w/ emulation, etc.) are accessing the
RS/6000 in order to run the Library public access catalog, which is one
of the options in a ksh menu program.
DYNIX, the catalog program,  is using the UniVerse implementation of
Pick, which is in turn layered over AIX.

Here's the problem:  when the users are done with the public catalog,
they sometimes turn off the terminal, which creates a 'cpu-hog' on our
system iff the user was using DYNIX at the time the plug was pulled.

By CPU hog, I mean that its number of cpu clicks on ps -ef, C column is
between 20 and 120 (normally a cpu-intensive process shows about 12
clicks - but if there are 20 hogs, each may have only 9, for example).

Clearly I need to get to the bottom of this problem.  Killing processes
is repetitive, timewasting, etc.  

SO!  The question is:  what signals are issued to processes associated
with a pty when the terminal powers down?  How does one handle those
signals to avoid the problem described? How does ksh handle these differently
than sh?

----------------------------------------------
fragments of typical code follow....
----------------------------------------------
~dynixlogin/.profile
	# ...set path, etc  deleted...
	cat <<TTYS
		   Please select your terminal type from the following list:"
			     0) Log out
			     1) Wyse or Adds Viewpoint
			     2) VT100
	TTYS
	echo -n "           Your choice? ":
	read ttype
	case "$ttype" in
		0) logout ;;
		1) TERM=wy30  ; export TERM ;;
		2) TERM=vt100 ; export TERM ;;
		*) TERM=$ttype ;;
	esac
	/usr/local/bin/libmenu
	logout
	exit
/usr/local/bin/libmenu
	
	trap "exit" 1

	optn=999
	until [ "$optn" -eq 0 ]
	do
		sleep 1
		optn=999
		until [ "$optn" -ge 0 -a "$optn" -le 5 ]
		do
			clear
			cat <<MENU
		1) ROGER     (Voskuyl Library On-line Catalog)
		2) ... other options deleted ...

MENU
			echo -n "\n           Please enter the option number you desire( 1-5 ) : "
			read optn 
			optn=`echo $optn  | tr -cd 12345`
			if [ -z "$optn" ]
			then
				optn=999
			fi
		done
		case "$optn" in  
		  1 ) clear 
		       Roger ;;
		  2 ) ... other options deleted ...
		esac

	done
	exit

~dynixlogin/Roger
	#!/bin/sh
	#  we use sh here, because uv had problems with ksh

	uv MM # this calls up UniVerse, and goes into the main menu
---------------------------------------
Anyone care to shed light on this subject?
-- 
----------==========[[[[[[[[[[]]]]]]]]]]==========----------
          John Rodkey, Director of Academic Computing, 
            Westmont College, Santa Barbara, CA
          rodkey@westmont.EDU, uunet!westmx!rodkey