#!/bin/bash
#
# This script is used by Xming/win32 clients to ensure that the connection is dropped when the command returns.
#

if [ $# == 0 ]; then
	echo "`basename $0`: wrong number of arguments!"
	echo "this script is meant to be used by winswitch - do not call it directly"
	echo "doing so may result in the wrong process being killed!"
	exit 1
fi

echo "Starting '$@'"
"$@"
exitcode=$?
echo "killing $PPID:"
ps -ef | grep -E "^$USER[ ]+$PPID"
kill $PPID
exit $exitcode
