I'm writing 2 different C++ programs that will run simultaneous and both need to access the same files, but cannot do so simultaneously. I need to have code that locks this section of code in both programs so that once one program starts processing the files, the other program will not be able to start until the other program is finished. I am running Linux kernel 2.6.9. Looking around, it seems like an option may be Posix named semaphores (like sem_open). Can someone confirm if they will work and/or is there a better way? I don't really need a full-blown semaphore but I didn't see any way to do a mutex that works between different processes. Also, right now my app isn't multi-threaded, but I'd like to have a solution that continues working if I multi-thread my app. Does anyone have any examples? Thanks!