lock [ -r ]
check lock ; if it doesnt exist acquire it. fd 7 is used for lockfile and should not be used by calling scripts using this function.
-r remove the lock