get_robust_list(2)

πŸ’– get_robust_list(2) β€” okay bestie, let's talk robust futex lists πŸ’–

so this is a page from the System Calls Manual (Linux girly through and through 🐧), and it's about get_robust_list and set_robust_list β€” the getter and the setter for your very own list of robust futexes. yeah. we're going there. stay with me πŸ’…


✨ NAME ✨

get_robust_list, set_robust_list β€” get/set the list of robust futexes πŸ’«

πŸ“š LIBRARY πŸ“š

Standard C library (libc, -lc)

πŸŽ€ SYNOPSIS πŸŽ€

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

long syscall(SYS_get_robust_list, int pid,
             struct robust_list_head **head_ptr, size_t *sizep);
long syscall(SYS_set_robust_list,
             struct robust_list_head *head, size_t size);
okay so heads up (pun fully intended 🫢): glibc provides no wrappers for these system calls, so you literally have to go through syscall(2). no cute little helper function for you. it's giving DIY. it's giving raw dogging the kernel πŸ’€

🌸 DESCRIPTION 🌸

These system calls deal with per-thread robust futex lists. and the tea is: these lists live in user space β€” the kernel only knows where the head of the list is. that's it. that's all it gets. πŸ™ˆ

  • A thread can tell the kernel where its robust futex list is at by using set_robust_list().
  • You can grab the address of a thread's robust futex list with get_robust_list().

πŸ¦‹ so what's the whole POINT of this list

The purpose of the robust futex list is to make sure that if a thread accidentally forgets to unlock a futex before it terminates or calls execve(2), any other thread waiting on that futex gets notified that the former owner has died. rip to them but somebody had to know ✨

That notification comes in two pieces, and bestie, both of them matter:

  1. The FUTEX_OWNER_DIED bit gets set in the futex word.
  2. The kernel performs a futex(2) FUTEX_WAKE operation on one of the threads waiting on that futex.

πŸ’œ get_robust_list()

get_robust_list() returns the head of the robust futex list of the thread whose thread ID you pass in pid.

  • If pid is 0, you get the head of the list for the calling thread. (self-love fr fr πŸ’–)
  • The list head gets stored in the location pointed to by head_ptr.
  • The size of the object pointed to by **head_ptr gets stored in sizep.

Permission to use get_robust_list() is governed by a ptrace access mode PTRACE_MODE_READ_REALCREDS check. see ptrace(2) for the full lore πŸ‘‘

πŸ’… set_robust_list()

set_robust_list() asks the kernel to record the head of the list of robust futexes owned by the calling thread.

  • head β€” the list head to record.
  • size β€” should be sizeof(*head).

🌈 RETURN VALUE 🌈

Both set_robust_list() and get_robust_list() return zero when everything worked out, and an error code otherwise. slay when zero, sad when not 😭

πŸ”₯ ERRORS πŸ”₯

set_robust_list() can fail with:

  • EINVAL β€” size does not equal sizeof(struct robust_list_head). yeah you gotta get that size exactly right, no rounding, no vibes-based sizing πŸŽ€

get_robust_list() can fail with:

  • EFAULT β€” the head of the robust futex list can't be stored at the location head.
  • EPERM β€” the calling process does not have permission to see the robust futex list of the thread with the thread ID pid, and does not have the CAP_SYS_PTRACE capability.
  • ESRCH β€” no thread with the thread ID pid could be found. she's not here, she never was πŸ’€

⭐ VERSIONS ⭐

These system calls were added in Linux 2.6.17. vintage but make it functional πŸ’«

πŸ‘‘ NOTES πŸ‘‘

  • These system calls are not needed by normal applications. (say it louder for the people in the back πŸ“£)
  • A thread can have only one robust futex list. so applications that want this functionality should really just use the robust mutexes provided by glibc. stop trying to do it yourself, bestie 🫢
  • In the initial implementation, a thread waiting on a futex was notified that the owner had died only if the owner terminated. Starting with Linux 2.6.28, that notification was extended to also cover the case where the owner performs an execve(2).
  • The thread IDs mentioned in the main text are kernel thread IDs, of the kind returned by clone(2) and gettid(2). important distinction, no cap 🧚

🌸 SEE ALSO 🌸


and that's the whole page, bestie πŸ’– you now know more about robust futex lists than 99% of the group chat. main character kernel-knowledge energy, lowkey.

okay bye ily, this was Linux man-pages 6.20, dated 2026-02-08 πŸŽ€ go forth and syscall responsibly ✨

πŸ“¦ 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
  • πŸ“œ the page's license: Linux-man-pages-copyleft
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms