The implementation of sem_timedwait which is in semaphore.c, is not POSIX compliant in regards to returning errors. It is supposed to return 0 or -1, and put the error in errno, which it doesn't do, but instead returns the error directly. Below is the patch to the latest in CVS. --- semaphore.c.orig 2004-04-26 14:29:11.000000000 -0400 +++ semaphore.c 2004-04-26 14:30:19.000000000 -0400 @@ -225,7 +225,8 @@ /* The standard requires that if the function would block and the time value is illegal, the function returns with an error. */ __pthread_unlock(&sem->__sem_lock); - return EINVAL; + errno = EINVAL; + return -1; } /* Set up extrication interface */ @@ -263,7 +264,8 @@ if (was_on_queue) { __pthread_set_own_extricate_if(self, 0); - return ETIMEDOUT; + errno = ETIMEDOUT; + return -1; } /* Eat the outstanding restart() from the signaller */
Created attachment 68 [details] Patch to semaphore.c
Fix commited to glibc CVS on 2004-04-29.