I want to implement a file level locking in my app.
A:
In short:
fd = open( "./foo", O_RDWR + O_EXLOCK);
But you first need to check if your fs supports it, see Exclusive File Access in Mac OS X. If not, you can lock 'by convention', using for example a lock file. This is explained in the article.
disown
2010-05-14 07:32:52