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, -1 is returned, and errno is set to indicate the error. classic. πŸ’€
  • On success, FUTEX_FD returns 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 in val is 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