1GET_ROBUST_LIST(2)            Linux System Calls            GET_ROBUST_LIST(2)
2
3
4

NAME

6       get_robust_list, set_robust_list - get/set list of robust futexes
7

SYNOPSIS

9       #include <linux/futex.h>   /* Definition of struct robust_list_head */
10       #include <sys/syscall.h>   /* Definition of SYS_* constants */
11       #include <unistd.h>
12
13       long syscall(SYS_get_robust_list, int pid,
14                    struct robust_list_head **head_ptr, size_t *len_ptr);
15       long syscall(SYS_set_robust_list,
16                    struct robust_list_head *head, size_t len);
17
18       Note:  glibc provides no wrappers for these system calls, necessitating
19       the use of syscall(2).
20

DESCRIPTION

22       These system calls deal with  per-thread  robust  futex  lists.   These
23       lists  are managed in user space: the kernel knows only about the loca‐
24       tion of the head of the list.  A thread can inform the  kernel  of  the
25       location of its robust futex list using set_robust_list().  The address
26       of  a  thread's  robust  futex  list  can  be  obtained  using  get_ro‐
27       bust_list().
28
29       The  purpose of the robust futex list is to ensure that if a thread ac‐
30       cidentally fails to unlock a futex before terminating  or  calling  ex‐
31       ecve(2),  another thread that is waiting on that futex is notified that
32       the former owner of the futex has died.  This notification consists  of
33       two  pieces: the FUTEX_OWNER_DIED bit is set in the futex word, and the
34       kernel performs a futex(2) FUTEX_WAKE operation on one of  the  threads
35       waiting on the futex.
36
37       The  get_robust_list() system call returns the head of the robust futex
38       list of the thread whose thread ID is specified in pid.  If pid  is  0,
39       the head of the list for the calling thread is returned.  The list head
40       is stored in the location pointed to by head_ptr.  The size of the  ob‐
41       ject pointed to by **head_ptr is stored in len_ptr.
42
43       Permission  to  employ get_robust_list() is governed by a ptrace access
44       mode PTRACE_MODE_READ_REALCREDS check; see ptrace(2).
45
46       The set_robust_list() system call requests the  kernel  to  record  the
47       head  of  the  list of robust futexes owned by the calling thread.  The
48       head argument is the list head to record.  The len argument  should  be
49       sizeof(*head).
50

RETURN VALUE

52       The  set_robust_list()  and  get_robust_list() system calls return zero
53       when the operation is successful, an error code otherwise.
54

ERRORS

56       The set_robust_list() system call can fail with the following error:
57
58       EINVAL len does not equal sizeof(struct robust_list_head).
59
60       The get_robust_list() system call can fail with the following errors:
61
62       EFAULT The head of the robust futex list can't be stored at  the  loca‐
63              tion head.
64
65       EPERM  The  calling  process does not have permission to see the robust
66              futex list of the thread with the thread ID pid,  and  does  not
67              have the CAP_SYS_PTRACE capability.
68
69       ESRCH  No thread with the thread ID pid could be found.
70

VERSIONS

72       These system calls were added in Linux 2.6.17.
73

NOTES

75       These system calls are not needed by normal applications.
76
77       A  thread  can  have only one robust futex list; therefore applications
78       that wish to use this functionality should use the robust mutexes  pro‐
79       vided by glibc.
80
81       In the initial implementation, a thread waiting on a futex was notified
82       that the owner had died only if the owner  terminated.   Starting  with
83       Linux  2.6.28,  notification was extended to include the case where the
84       owner performs an execve(2).
85
86       The thread IDs mentioned in the main text are kernel thread IDs of  the
87       kind returned by clone(2) and gettid(2).
88

SEE ALSO

90       futex(2), pthread_mutexattr_setrobust(3)
91
92       Documentation/robust-futexes.txt and Documentation/robust-futex-ABI.txt
93       in the Linux kernel source tree
94

COLOPHON

96       This page is part of release 5.12 of the Linux  man-pages  project.   A
97       description  of  the project, information about reporting bugs, and the
98       latest    version    of    this    page,    can     be     found     at
99       https://www.kernel.org/doc/man-pages/.
100
101
102
103Linux                             2021-03-22                GET_ROBUST_LIST(2)
Impressum