| 1 |
.\" Copyright, the authors of the Linux man-pages project |
| 2 |
.\" |
| 3 |
.\" %%%LICENSE_START(FREELY_REDISTRIBUTABLE) |
| 4 |
.\" may be freely modified and distributed |
| 5 |
.\" %%%LICENSE_END |
| 6 |
.\" |
| 7 |
.TH FUTEX_FD 2const 2025-05-30 "Linux man-pages 6.18" |
| 8 |
.SH NAME |
| 9 |
FUTEX_FD \- create a file descriptor associated with a futex |
| 10 |
.SH LIBRARY |
| 11 |
Standard C library |
| 12 |
.RI ( libc ,\~ \-lc ) |
| 13 |
.SH SYNOPSIS |
| 14 |
.nf |
| 15 |
.BR "#include <linux/futex.h>" " /* Definition of " FUTEX_* " constants */" |
| 16 |
.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */" |
| 17 |
.B #include <unistd.h> |
| 18 |
.P |
| 19 |
.B [[deprecated]] |
| 20 |
.BI "long syscall(SYS_futex, uint32_t *" uaddr ", FUTEX_FD, uint32_t " val ); |
| 21 |
.fi |
| 22 |
.SH DESCRIPTION |
| 23 |
This operation creates a file descriptor that is associated with |
| 24 |
the futex at |
| 25 |
.IR uaddr . |
| 26 |
The caller must close the returned file descriptor after use. |
| 27 |
.P |
| 28 |
When another process or thread performs a |
| 29 |
.BR FUTEX_WAKE (2const) |
| 30 |
on the futex word, the file descriptor indicates as being readable with |
| 31 |
.BR select (2), |
| 32 |
.BR poll (2), |
| 33 |
and |
| 34 |
.BR epoll (7) |
| 35 |
.P |
| 36 |
The file descriptor can be used to obtain asynchronous notifications: if |
| 37 |
.I val |
| 38 |
is nonzero, then, when another process or thread executes a |
| 39 |
.BR FUTEX_WAKE (2const), |
| 40 |
the caller will receive the signal number that was passed in |
| 41 |
.IR val . |
| 42 |
.\" |
| 43 |
.SH RETURN VALUE |
| 44 |
On error, |
| 45 |
\-1 is returned, |
| 46 |
and |
| 47 |
.I errno |
| 48 |
is set to indicate the error. |
| 49 |
.P |
| 50 |
On success, |
| 51 |
.B FUTEX_FD |
| 52 |
Returns the new file descriptor associated with the futex. |
| 53 |
.SH ERRORS |
| 54 |
See |
| 55 |
.BR futex (2). |
| 56 |
.TP |
| 57 |
.B EINVAL |
| 58 |
The signal number supplied in |
| 59 |
.I val |
| 60 |
is invalid. |
| 61 |
.TP |
| 62 |
.B ENFILE |
| 63 |
The system-wide limit on the total number of open files has been reached. |
| 64 |
.SH STANDARDS |
| 65 |
Linux. |
| 66 |
.SH HISTORY |
| 67 |
From Linux 2.6.0 up to and including Linux 2.6.25. |
| 68 |
.\" Strictly speaking, from Linux 2.5.x to Linux 2.6.25 |
| 69 |
.P |
| 70 |
Because it was inherently racy, |
| 71 |
.B FUTEX_FD |
| 72 |
has been removed |
| 73 |
.\" commit 82af7aca56c67061420d618cc5a30f0fd4106b80 |
| 74 |
from Linux 2.6.26 onward. |
| 75 |
.SH SEE ALSO |
| 76 |
.BR futex (2) |