#!/bin/sh
#
#	Script to reproduce PIR 2793
#
#	To run this program type 'nohup behavior_test'
#
#	Related files forthis test are:
#	
#		./behavior.xinit
#		./behavior.Xdefs
#		./behavior.mwmrc
#

SYSTEM=`uname -a | awk -F' ' '{print $1}'`
CURR_DIR=`pwd`
XENVIRONMENT=`pwd`

# get the xinit process and kill it
#	look for " xinit" or ".../xinit"
#	this should give you only things that really are xinit
#	remove all leading whitespace and replace multiple
#	tabs/spaces with 1 space
if [ ${SYSTEM} = "HP-UX" ]
then
# HP version
	X_LINE=`ps -ef | grep X | egrep -v "xinit|grep"`
	BETTER_X_LINE=`echo ${X_LINE} | sed -e 's/^[	 ]*//
		s/[	 ][	 ]*/ /g'`
	X_PID=`echo ${BETTER_X_LINE} | cut -d' ' -f2`
else
# others, like DEC version
    X_LINE=`ps -axw | grep X | egrep -v "xinit|grep"`
	BETTER_X_LINE=`echo ${X_LINE} | sed -e 's/^[   ]*//
		s/[  ][  ]*/ /g'`
	X_PID=`echo ${BETTER_X_LINE} | cut -d' ' -f1`
fi

	kill ${X_PID}
# start new X session
	sleep 5
#
xinit ${CURR_DIR}/behavior.xinit
# end of script
