Is it good practice to use mkdir as file-based locking on linux?
问题 I wanted to quickly implement some sort of locking in perl program on linux, which would be shareable between different processes. So I used mkdir as an atomic operation, which returns 1 if the directory doesn't exist and 0 if it does. I remove the directory right after the critical section. Now, it was pointed to me that it's not a good practice in general (independently on the language). I think it's quite OK, but I would like to ask your opinion. edit: to show an example, my code looked