Function to properly do a lockfile in bash.