1) Is this actually a hanging session? I don't assume so, because there is a ttsession present, which will keep the script from doing anything. Furthermore, the basic xterm is not a child of init but of gsl_09.07.007 which seems to be the "normal" situation.
Could it be that the problem arises the very moment this obscure gsl_09.07.007 vanishes and leaves xterm orphaned?
2) No wonder that the script fails, with all those extra linefeeds! Where do they come from?
#!/bin/ksh
ps -ef -o user,pid,args | grep catintr | while read line
do
set $line
USER=$1
PID=$2
CMD=$3
if [ $(ps -ef -o user,comm | grep $USER | grep -c dtsession) -ne 0 \
-o $(ps -ef -o user,comm | grep $USER | grep -c ttsession) -ne 0 ]
then :
else
for pid in $(proctree $PID 2>/dev/null | awk '{print $1}' | sort -nu)
do
if [ $(ps -f -o user= -p $pid 2>/dev/null) = $USER ]
then
ps -fp $pid
echo kill $pid
fi
done
echo "---"
fi
done
exit
You can't split lines in a shell script wherever you like. There are some syntax rules to be observed!
wmp