| aug2004.tar |
Listing 8 get_num_resources()
{
# Echos the number of resources that a semaphore has. (See also
# Init_semaphore). Return the contents of the specified semaphore's
# resource file, and return 0 if the semaphore has been initialized;
local FUNC_NAME=get_num_resources
${TRACE:-trace $FUNC_NAME $@}
local semaphore=$1
local resources_file=$HOME_DIR/$semaphore/$RESOURCES_FILENAME
assert_semaphore $semaphore
integer num_resources=$(cat -s $resources_file)
echo ${num_resources:-0}
} |