Thread (6 messages) 6 messages, 3 authors, 2025-01-03

signal(7): why does it say that pthread_mutex_lock() and thread_cond_wait() can fail with EINTR?

From: Arkadiusz Drabczyk <hidden>
Date: 2025-01-01 22:21:09

In man/man7/signal.7 it says:
If a blocked call to one of the following interfaces is interrupted
by a signal handler, then the call is automatically restarted after
the signal handler returns if the SA_RESTART flag was used;
otherwise the call fails with the error EINTR:
(...)
• pthread_mutex_lock(3), pthread_cond_wait(3), and related APIs.
I don't understand this, in my experiments neither
pthread_mutex_lock() nor pthread_cond_wait() return EINTR even if
signal handler was installed without using SA_RESTART flag. The
underlying futex() call indeed fails with EINTR but it's called again
by both glibc and musl. Additionally both
man/man3/pthread_mutex_lock.3 and man/man3/pthread_cond_wait.3 say
that these functions do not return EINTR.

Is my understanding of the signal.7 wrong or does it need some work?

-- 
Arkadiusz Drabczyk [off-list ref]
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help