utils.sh revision 3261
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
#
# Verify directory context variables are set
if [ "${TESTJAVA}" = "" ] ; then
echo "TESTJAVA not set. Test cannot execute. Failed."
exit 1
fi
if [ "${TESTCLASSES}" = "" ] ; then
TESTCLASSES="."
fi
if [ "${TESTSRC}" = "" ] ; then
TESTSRC="."
fi
PS=";"
FS="\\"
;;
*)
PS=":"
FS="/"
;;
esac
}
Windows_95 | Windows_98 | Windows_ME | CYGWIN* )
echo "Test bypassed: jvmstat feature not supported on ${OS}"
exit 0
;;
Windows_*)
# verify that the tmp directory supports persistent ACLs, which
# are required for jvmstat to enable its shared memory feature.
# NOTE: FAT type files systems do not support ACLs, but NTFS files
# systems do.
#
if [ "${TMPDRIVE}" = "" ] ; then
echo "Could not get temp directory drive letter"
exit 1
fi
echo "temp file system characteristics:"
case $? in
0)
;;
1)
echo "Test bypassed: jvmstat feature disabled because the temp"
echo "directory doesn't support persistent ACLs"
exit 0
;;
2)
echo "Could not get temp directory file system features"
exit 1
;;
*)
echo "Unexpected return code from grep - $?"
exit 1
;;
esac
;;
esac
}
# function to kill the process with the given process id
kill_pid=$1
if [ "${kill_pid}" = "" ]
then
echo "kill_proc(): null pid: ignored"
return
fi
then
echo "kill_proc(): invalid pid: ${kill_pid}: ignored"
return
fi
Windows_*)
case ${SHELL_VERSION} in
[1234567].* | 8.[12345].*)
# when starting processes in the background, mks creates an
# intervening between the parent process and the background
# process. The pid acquired for background process as acquired
# by the $! shell variable is actually the pid of the invervening
# shell and not that of the background process. Sending a specific
# signal to the intervening shell will only effects the intervening
# shell and not the background process, thus leaving the background
# process running. The following code assumes that the pid passed
# into this function as ${kill_pid}, was acquired by $!. Therefore,
# in order to kill the background process, we must first find the
# children of ${kill_pid} (should be only one child) and kill them.
children=`mks_children ${kill_pid}`
echo "killing children of ${kill_pid}: ${children}"
done
;;
*)
# in mks 8.6 and later, the pid returned in $! is now the pid
# of the background process and not that of the intervening shell.
;;
esac
;;
*)
;;
esac
}
ppid=$1
BEGIN { pids="" }
{ pids = pids $1 " " }
END { print pids }'
}
kpid=$1
# verify that the process exists and we can signal it
if [ $? -ne 0 ]
then
echo "Could not signal >${kpid}<"
echo "process information :"
return
fi
if [ $? -eq 0 ]
then
sleep 2
# check if it's still hanging around
if [ $? -eq 0 ]
then
# it's still lingering, now it it hard
if [ $? -ne 0 ]
then
echo "Could not kill ${kpid}!"
fi
fi
else
echo "Error sending term signal to ${kpid}!"
fi
}
# check to see if a port is free
{
if [ "${inuse}" = "" ] ; then
echo "free"
else
echo "inuse"
fi
}
# Get a free port, where port+1 is also free, return 0 when giving up
freePort()
{
start=3000
else
break
fi
done
port1="0"
fi
echo "${port1}"
}