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:
- The
FUTEX_OWNER_DIEDbit gets set in the futex word. - The kernel performs a
futex(2)FUTEX_WAKEoperation 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
pidis0, 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_ptrgets stored insizep.
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 besizeof(*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βsizedoes not equalsizeof(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 locationhead.EPERMβ the calling process does not have permission to see the robust futex list of the thread with the thread IDpid, and does not have theCAP_SYS_PTRACEcapability.ESRCHβ no thread with the thread IDpidcould 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)andgettid(2). important distinction, no cap π§
πΈ SEE ALSO πΈ
futex(2)pthread_mutexattr_setrobust(3)Documentation/robust-futexes.rstandDocumentation/robust-futex-ABI.rstin the Linux kernel source tree
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
- Copyright 2006, Red Hat, Inc
- Copyright 2017, Michael Kerrisk <mtk.manpages@gmail.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms