Unnamed POSIX shared semaphores
Vlad Galu
dudu at dudu.ro
Mon Jun 1 15:34:04 UTC 2009
Hello,
According to sem_init(3), we can't have shared unnamed semaphores.
However, the following code snippet seems to work just fine:
-- cut here --
sem_t semaphore;
if (sem_init(&semaphore, 1, 10) < 0)
std::cout << "Couldn't init semaphore: " <<
strerror(errno) << std::endl;
if (sem_wait(&semaphore) < 0)
std::cout << "Couldn't decrement semaphore: " <<
strerror(errno) << std::endl;
int val;
sem_getvalue(&semaphore, &val);
std::cout << "Value is " << val << std::endl;
-- and here --
Is this a case where sem_init() silently reports success, or should be
the man page get an update?
Thanks,
Vlad
More information about the freebsd-stable
mailing list