[original comment removed]
I just read the sem_init man page - apparently you can use unnamed semaphores across processes (via mmap).
Now the interesting bit - you can use another flag in the mmap to see if the semaphore has been initialized - except of course you need a lock of some sort to do that (which brings you back to a named semaphore).
How to determine if a semaphore has been initialized? Well, you can start out with an mmap() that's all zeroed out; that makes it a bit easier to check the semaphore. You can also look at the code to see how the semaphore is implemented and you should get an idea of how to test.
[yet another edit]
Blah ... back to IPC101 - according to the man pages:
Quote:
|
A semaphore is an integer whose value is never allowed to fall below zero.
|
So if the mmap area used by the semaphores is initialized with, say, -1, then you can easily test if the sempahore had been init'ed.