pthread_cond_wait and pthread_cond_timedwait can also return EPERM Attached a reproducer. I did not test the EINTR case but it looks logical to me. Signed-off-by: Jan Kratochvil <jan@xxxxxxxxxxxxxxxxx>
#define _GNU_SOURCE #include <pthread.h> #include <assert.h> #include <stdio.h> #include <errno.h> #include <string.h> int main(void) { // pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER; // not reproducible pthread_mutex_t mut = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; pthread_cond_t cond = PTHREAD_COND_INITIALIZER; int err; // err=pthread_mutex_lock(&mut); // assert(!err); err=pthread_cond_wait(&cond, &mut); if (err) { printf("%d=%s\n",err,strerror(err)); return 1; } return 0; }
diff --git a/man/man3/pthread_cond_init.3 b/man/man3/pthread_cond_init.3 index 42e7eac..6e21b54 100644 --- a/man/man3/pthread_cond_init.3 +++ b/man/man3/pthread_cond_init.3 @@ -141,15 +141,28 @@ and a non-zero error code on error. . .SH ERRORS \fBpthread_cond_init\fP, -\fBpthread_cond_signal\fP, -\fBpthread_cond_broadcast\fP, -and \fBpthread_cond_wait\fP +\fBpthread_cond_signal\fP +and \fBpthread_cond_broadcast\fP, never return an error code. .P +The \fBpthread_cond_wait\fP function returns +the following error codes on error: +.RS +.TP +\fBEPERM\fP +\fBmutex\fP is not locked. +.TP +\fBEINTR\fP +\fBpthread_cond_wait\fP was interrupted by a signal. +.RE +.P The \fBpthread_cond_timedwait\fP function returns the following error codes on error: .RS .TP +\fBEPERM\fP +\fBmutex\fP is not locked. +.TP \fBETIMEDOUT\fP The condition variable was not signaled until the timeout specified by \fIabstime\fP.