tags:

views:

20

answers:

1

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