Reputation: 7563
How can I create a mutex in linux that will work with different processes and will have string name?
I want something similar to CreateMutex
in Windows OS.
Upvotes: 0
Views: 1294
Reputation: 20997
There's a really nice freeware book Advanced Linux Programming with chapter on Interprocess communication especially 5.2 Processes Semaphores:
Linux provides a distinct alternate implementation of semaphores that can be used for synchronizing processes (called process semaphores or sometimes System V semaphores). Process sem- aphores are allocated, used, and deallocated like shared memory segments.
There's really thorough explanation and many examples so I recommend taking a look.
Upvotes: 3
Reputation: 59987
Use a semaphore - see http://man7.org/linux/man-pages/man7/sem_overview.7.html.
This will give you the same as a mutex and you can name them
Upvotes: 3