This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
Re: [PATCH] Fix return value and errno set by sem_init(), sem_destroy() and sem_close()
- From: Christopher Faylor <cgf-use-the-mailinglist-please at cygwin dot com>
- To: cygwin-patches at cygwin dot com
- Date: Mon, 28 Mar 2011 18:16:57 -0400
- Subject: Re: [PATCH] Fix return value and errno set by sem_init(), sem_destroy() and sem_close()
- References: <4D91082B.1050102@dronecode.org.uk>
- Reply-to: cygwin-patches at cygwin dot com
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 [1], 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 <jon.turney@dronecode.org.uk>
>
> * 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.
>
>[1] http://cygwin.com/ml/cygwin/2002-02/msg01379.html
Looks good. Please check in ASAP so this will make it into 1.7.9.
Thanks.
cgf