[libc-commits] [libc] [libc] EAGAIN and EWOULDBLOCK should be treated as success in futex wait (PR #203407)
via libc-commits
libc-commits at lists.llvm.org
Thu Jun 11 14:46:43 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Schrodinger ZHU Yifan (SchrodingerZhu)
<details>
<summary>Changes</summary>
The `futex` wait function means waiting until a real change has been detected. We should not reject valid EAGAIN/EWOULDBLOCK kernel detection as failures.
Pure human code.
---
Full diff: https://github.com/llvm/llvm-project/pull/203407.diff
1 Files Affected:
- (modified) libc/src/__support/threads/linux/futex_utils.h (+5)
``````````diff
diff --git a/libc/src/__support/threads/linux/futex_utils.h b/libc/src/__support/threads/linux/futex_utils.h
index ff6b5d526a3c1..61c1b7353e05b 100644
--- a/libc/src/__support/threads/linux/futex_utils.h
+++ b/libc/src/__support/threads/linux/futex_utils.h
@@ -66,6 +66,11 @@ class Futex : public cpp::Atomic<FutexWordType> {
if (ret == -EINTR)
continue;
+ // the value pointed to by uaddr was not equal to the expected
+ // value val at the time of the call (EAGAIN or EWOULDBLOCK).
+ if (ret == -EAGAIN || ret == -EWOULDBLOCK)
+ return 0;
+
if (ret < 0)
return cpp::unexpected(-ret);
return ret;
``````````
</details>
https://github.com/llvm/llvm-project/pull/203407
More information about the libc-commits
mailing list