[PATCH] Fix return value and errno set by sem_init(), sem_destroy() and sem_close()
Mon Mar 28 22:17:00 GMT 2011
On Mon, Mar 28, 2011 at 11:14:03PM +0100, Jon TURNEY wrote:
>While looking into some mysterious failures of sem_init() in python, I was
>somewhat surprised to find the following comment in python/thread_pthread.h:
>> * As of February 2002, Cygwin thread implementations mistakenly report error
>> * codes in the return value of the sem_ calls (like the pthread_ functions).
>> * Correct implementations return -1 and put the code in errno. This supports
>> * either.
>While this comment refers to sem_wait() and sem_trywait(), which seem to have
>been fixed since , it seems that sem_init(), sem_destroy() and sem_close()
>are still non-conformant with SUS in that (i) they do not set errno, and (ii)
>they don't return -1 on failure, instead returning the value which should be
>set as errno.
>2011-03-28 Jon TURNEY <firstname.lastname@example.org>
> * thread.cc (semaphore::init, destroy, close): Standards conformance
> fix. On a failure, return -1 and set errno.
> * thread.h (semaphore::terminate): Save errno since semaphore::close()
> may now modify it.
Looks good. Please check in ASAP so this will make it into 1.7.9.
More information about the Cygwin-patches