I'm trying to do some simple file locking in freebsd 7 with userland apps. I'm having some problems with atomicity, though, with advisory locks (flock).
Advisory locks present a problem for me because you:
1) Check to see if there is an advisory lock on the file.
2) If no lock, then you lock the file and do your business with it.
But what if the process is put to sleep between steps 1 and 2?
Is there a userland function that will perform steps 1 and 2 atomically? My program is not using pthreads, either. This is between two processes that have forked. Any such beast available?
Advisory locks present a problem for me because you:
1) Check to see if there is an advisory lock on the file.
2) If no lock, then you lock the file and do your business with it.
But what if the process is put to sleep between steps 1 and 2?
Is there a userland function that will perform steps 1 and 2 atomically? My program is not using pthreads, either. This is between two processes that have forked. Any such beast available?