language hipsters also have never used C, if they had they

Today was the first time that I ran into an unexpected race condition. With a bash script for a self made automounter. The automounter is invoked by udev. I did not expect udev to run the same script twice parallely, and so, an error occured.

The theoretical solution is simple, use locking. But in fact, I never have seen bash scripts doing something beyond

[ -e my_lock_file ] || touch my_lock_file && ...
to create locks, and this is dangerous, because between testing and touching a logfile, there might be the time for another test - the locking is not atomic.

I would have been surprised if this problem did not have a solution, and in fact, it does:

lockfile-create /tmp/my.lock
...
lockfile-remove /tmp/my.lock
Nice. Especially, it allows simple experiments with lockfiles through remote file systems.