I had the same problem and came to the conclusion that mkpidlock() is not supposed to lock the file passed as first argument. Rather, it creates a file that acts as a lock. The fact that the file exists signals other processes that the lock is already taken by someone. I think the reason behind this is that it is very difficult to implement a cross-platform file lock for Linux, Windos, MacOS, etc. So we should use it like so:
mkpidlock("test.txt.lock") do
open("test.txt", "a") do io
write(io, "Meow")
end
end