diff options
-rw-r--r-- | mit-pthreads/pthreads/semaphore.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/mit-pthreads/pthreads/semaphore.c b/mit-pthreads/pthreads/semaphore.c index 5516af1f4e3..0af54beca8a 100644 --- a/mit-pthreads/pthreads/semaphore.c +++ b/mit-pthreads/pthreads/semaphore.c @@ -32,7 +32,9 @@ int sem_destroy(sem_t * sem) int sem_wait(sem_t * sem) { - while ((errno=pthread_mutex_lock(&sem->mutex)) || !sem->count) + if ((errno=pthread_mutex_lock(&sem->mutex))) + return -1; + while (!sem->count) pthread_cond_wait(&sem->cond, &sem->mutex); if (errno) return -1; |