The mutex_trylock() and mutex_unlock() functions use $$ to determine the
current process's PID. However, this variable always reflects the PID of
the original shell. This commit changes the functions to use $BASHPID to
determine the PID of the current shell.
lock="$1"
- if ! ln -s "$$" "$lock" &> /dev/null; then
+ if ! ln -s "$BASHPID" "$lock" &> /dev/null; then
return 1
fi
return 1
fi
- if [ "$owner" -ne "$$" ]; then
+ if [ "$owner" -ne "$BASHPID" ]; then
return 2
fi