Boost C++ Libraries: Ticket #5622: interprocess::named_semaphore::remove return value broken on POSIX systems https://svn.boost.org/trac10/ticket/5622 <p> <strong>static bool named_semaphore::remove(const char *name)</strong> is documented as "Returns false on error", which is broken on POSIX platforms if BOOST_INTERPROCESS_NAMED_SEMAPHORE_USES_POSIX_SEMAPHORES is enabled. </p> <p> <strong>named_semaphore::remove()</strong> (interprocess/sync/named_semaphore.hpp:166) calls <strong>static bool detail::named_semaphore_wrapper::remove(const char *name)</strong>, which (interprocess/sync/posix/semaphore_wrapper.hpp:229) calls <strong>inline bool semaphore_unlink(const char *name)</strong> (:106). This function uses the POSIX API call sem_unlink() (:115) to do the unlinking: </p> <p> <code> return 0 != sem_unlink(sem_str.c_str()); </code> </p> <p> This makes semaphore_unlink() return <strong>false</strong> if sem_unlink() returns 0. POSIX' sem_unlink() is documented to return 0 on <strong>success</strong>, though: "Upon successful completion, the sem_unlink() function shall return a value of 0." (POSIX API docs) interprocess/sync/posix/semaphore_wrapper.hpp:115 should be changed to the following: </p> <p> <code> return 0 == sem_unlink(sem_str.c_str()); </code> </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5622 Trac 1.4.3 Horst Schirmeier <horst@…> Mon, 20 Jun 2011 19:44:05 GMT attachment set https://svn.boost.org/trac10/ticket/5622 https://svn.boost.org/trac10/ticket/5622 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">syncbug.cc</span> </li> </ul> <p> Code snippet to reproduce the bug </p> Ticket Horst Schirmeier <horst@…> Mon, 20 Jun 2011 19:45:51 GMT attachment set https://svn.boost.org/trac10/ticket/5622 https://svn.boost.org/trac10/ticket/5622 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">remove-semaphore.diff</span> </li> </ul> <p> Patch for expected behaviour (against current development trunk SVN head) </p> Ticket Ion Gaztañaga Sat, 24 Dec 2011 11:08:41 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/5622#comment:1 https://svn.boost.org/trac10/ticket/5622#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Thanks for the report. Fixed in trunk. </p> Ticket