FUTEX_FD(2const)
π FUTEX_FD(2const) π
okay bestie, so this is a page from the <italic>Linux man-pages</italic> set β section 2const to be exact β and no cap, it's a β¨ historic β¨ one. Buckle up, it's giving "vintage Linux lore". π¦
πΈ NAME πΈ
FUTEX_FD β make a file descriptor that's besties with a futex π«Ά
π LIBRARY π
Standard C library (libc, -lc) β the usual, she's always there for you π
β¨ SYNOPSIS β¨
#include <linux/futex.h> /* Definition of FUTEX_* constants */
#include <sys/syscall.h> /* Definition of SYS_* constants */
#include <unistd.h>
[[deprecated]]
long syscall(SYS_futex, uint32_t *uaddr, FUTEX_FD, uint32_t val);
see that [[deprecated]] sitting there? yeah. she's marked. π
π DESCRIPTION π
So this operation creates a file descriptor that is associated with the futex at uaddr. Simple as that. And listen β the caller must close the returned file descriptor after use. That's not optional, that's the rules, periodt. π₯
Now the fun part: when another process or thread performs a FUTEX_WAKE(2const) on the futex word, that file descriptor shows up as being readable with select(2), poll(2), and epoll(7). Like, it's literally vibing and saying "hey, something happened" β¨
And it can also be used to obtain asynchronous notifications β here's the tea: if val is nonzero, then when another process or thread executes a FUTEX_WAKE(2const), the caller will receive the signal number that was passed in val. iconic behavior, ngl. π
π RETURN VALUE π
- On error,
-1is returned, anderrnois set to indicate the error. classic. π - On success,
FUTEX_FDreturns the new file descriptor associated with the futex. slay. π
β ERRORS β
See futex(2) for the full rundown bestie, plus these two special guests:
EINVALβ the signal number supplied invalis invalid. like girl, that's not a real signal number πENFILEβ the system-wide limit on the total number of open files has been reached. too many open files, the whole system said "no more". π
π STANDARDS π
Linux. that's it, that's the standard. π§
π HISTORY π
Okay so here's the drama: FUTEX_FD lived from Linux 2.6.0 up to and including Linux 2.6.25. a whole era. π°οΈ
But because it was inherently racy, FUTEX_FD has been removed from Linux 2.6.26 onward. gone. deleted. she did not survive the vibe check. π
β οΈ fr fr β don't try to use this on modern kernels, bestie. it's not there anymore. this is museum content. ποΈ
π¦ SEE ALSO π¦
and that's the whole page, bestie!! π this was from the <italic>Linux man-pages</italic>, version 6.20, dated 2025-05-30 β so when you cite it, cite it cute. mwah, love u, go close your file descriptors. πβ¨π«Ά
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms