---
name: "FUTEX_WAIT"
section: "2const"
platform: "linux"
package: "man-pages"
version: "6.19-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/FUTEX_WAIT"
---

# FUTEX\_WAIT(2const)

sleep waiting for a FUTEX\_WAKE operation

## NAME

FUTEX\_WAIT - sleep waiting for a FUTEX\_WAKE operation

## LIBRARY

Standard C library (*libc*, *-lc*)

## SYNOPSIS

```
#include <linux/futex.h>  /* Definition of FUTEX_* constants */
#include <sys/syscall.h>  /* Definition of SYS_* constants */
#include <unistd.h>
```

**long syscall(SYS\_futex, uint32\_t \****uaddr***, FUTEX\_WAIT, uint32\_t** *val***,**              **const struct timespec \*\_Nullable** *timeout***);**

## DESCRIPTION

This operation tests that the value at the futex word pointed to by the address *uaddr* still contains the expected value *val*, and if so, then sleeps waiting for a [**FUTEX\_WAKE**(2const)](/FUTEX_WAKE/2const.md) operation on the futex word.

The load of the value of the futex word is an atomic memory access (i.e., using atomic machine instructions of the respective architecture). This load, the comparison with the expected value, and starting to sleep are performed atomically and totally ordered with respect to other futex operations on the same futex word.

If the thread starts to sleep, it is considered a waiter on this futex word. If the futex value does not match *val*, then the call fails immediately with the error **EAGAIN**.

The purpose of the comparison with the expected value is to prevent lost wake-ups. If another thread changed the value of the futex word after the calling thread decided to block based on the prior value, and if the other thread executed a [**FUTEX\_WAKE**(2const)](/FUTEX_WAKE/2const.md) operation (or similar wake-up) after the value change and before this **FUTEX\_WAIT** operation, then the calling thread will observe the value change and will not start to sleep.

If the *timeout* is not NULL, the structure it points to specifies a timeout for the wait. (This interval will be rounded up to the system clock granularity, and is guaranteed not to expire early.) If *timeout* is NULL, the call blocks indefinitely.

## RETURN VALUE

On error, -1 is returned, and *errno* is set to indicate the error.

On success, **FUTEX\_WAIT** returns 0 if the caller was woken up. Note that a wake-up can also be caused by common futex usage patterns in unrelated code that happened to have previously used the futex word's memory location (e.g., typical futex-based implementations of Pthreads mutexes can cause this under some conditions). Therefore, callers should always conservatively assume that a return value of 0 can mean a spurious wake-up, and use the futex word's value (i.e., the user-space synchronization scheme) to decide whether to continue to block or not.

## ERRORS

See [**futex**(2)](/futex/2.md).

- **EAGAIN** or **EWOULDBLOCK**

  The value pointed to by *uaddr* was not equal to the expected value *val* at the time of the call.

- **EFAULT**

  *timeout* did not point to a valid user-space address.

- **EINTR**

  The operation was interrupted by a signal (see [**signal**(7)](/signal/7.md)). Before Linux 2.6.22, this error could also be returned for a spurious wakeup; since Linux 2.6.22, this no longer happens.

- **EINVAL**

  The supplied *timeout* argument was invalid (*tv\_sec* was less than zero, or *tv\_nsec* was not less than 1,000,000,000).

- **ETIMEDOUT**

  The timeout expired before the operation completed.

## STANDARDS

Linux.

## HISTORY

Linux 2.6.0.

## CAVEATS

*timeout* is interpreted as a *relative* value. This differs from other futex operations, where *timeout* is interpreted as an absolute value. To obtain the equivalent of **FUTEX\_WAIT** with an absolute timeout, employ [**FUTEX\_WAIT\_BITSET**(2const)](/FUTEX_WAIT_BITSET/2const.md) with *val3* specified as **FUTEX\_BITSET\_MATCH\_ANY**.

## SEE ALSO

[**futex**(2)](/futex/2.md)
