Date: Mon, 1 Jun 2009 18:33:42 +0300 From: Vlad Galu <dudu@dudu.ro> To: freebsd-stable@freebsd.org Subject: Unnamed POSIX shared semaphores Message-ID: <ad79ad6b0906010833y20042080td1ebe0d3bfffbdc5@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?ad79ad6b0906010833y20042080td1ebe0d3bfffbdc5>