public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] pthread_cond_wait and pthread_cond_timedwait can also return EPERM
@ 2024-10-09 12:53 Jan Kratochvil
  2024-10-10 10:32 ` Florian Weimer
  0 siblings, 1 reply; 7+ messages in thread
From: Jan Kratochvil @ 2024-10-09 12:53 UTC (permalink / raw)
  To: Alejandro Colomar; +Cc: linux-man

[-- Attachment #1: Type: text/plain, Size: 205 bytes --]

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@jankratochvil.net>

[-- Attachment #2: wait.c --]
[-- Type: text/plain, Size: 510 bytes --]

#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;
}

[-- Attachment #3: pthread_cond_init.3.patch --]
[-- Type: text/plain, Size: 919 bytes --]

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.

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-11-01 13:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-09 12:53 [patch] pthread_cond_wait and pthread_cond_timedwait can also return EPERM Jan Kratochvil
2024-10-10 10:32 ` Florian Weimer
2024-10-10 11:46   ` [patch] pthread_cond_wait and pthread_cond_timedwait can also return EPERMignalignal Jan Kratochvil
2024-10-10 12:25     ` Florian Weimer
2024-10-10 12:39       ` [patchv3] pthread_cond_wait and pthread_cond_timedwait can also return EPERM Jan Kratochvil
2024-11-01 13:10         ` Alejandro Colomar
2024-11-01 13:16           ` Alejandro Colomar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox