]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/get_robust_list.2
man*/: srcfix (Use .P instead of .PP or .LP)
[thirdparty/man-pages.git] / man2 / get_robust_list.2
CommitLineData
1f62bc9e
IV
1.\" Copyright (C) 2006 Red Hat, Inc. All Rights Reserved.
2.\" Written by Ivana Varekova <varekova@redhat.com>
34821bdd 3.\" and Copyright (c) 2017, Michael Kerrisk <mtk.manpages@gmail.com>
1f62bc9e 4.\"
5fbde956 5.\" SPDX-License-Identifier: Linux-man-pages-copyleft
1f62bc9e 6.\"
ce50b4c3 7.\" FIXME Something could be added to this page (or exit(2))
d316ef31 8.\" about exit_robust_list processing
1f62bc9e 9.\"
4c1c5274 10.TH get_robust_list 2 (date) "Linux man-pages (unreleased)"
1f62bc9e 11.SH NAME
ce50b4c3 12get_robust_list, set_robust_list \- get/set list of robust futexes
04110e32
AC
13.SH LIBRARY
14Standard C library
8fc3b2cf 15.RI ( libc ", " \-lc )
1f62bc9e
IV
16.SH SYNOPSIS
17.nf
eb4a40e0 18.BR "#include <linux/futex.h>" \
843c0193
MK
19" /* Definition of " "struct robust_list_head" " */"
20.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */"
eb4a40e0 21.B #include <unistd.h>
c6d039a3 22.P
eb4a40e0
AC
23.BI "long syscall(SYS_get_robust_list, int " pid ,
24.BI " struct robust_list_head **" head_ptr ", size_t *" len_ptr );
1ae6b2c7 25.B long syscall(SYS_set_robust_list,
eb4a40e0 26.BI " struct robust_list_head *" head ", size_t " len );
1f62bc9e 27.fi
c6d039a3 28.P
bc2813df
AC
29.IR Note :
30glibc provides no wrappers for these system calls,
31necessitating the use of
32.BR syscall (2).
1f62bc9e 33.SH DESCRIPTION
34821bdd
MK
34These system calls deal with per-thread robust futex lists.
35These lists are managed in user space:
36the kernel knows only about the location of the head of the list.
37A thread can inform the kernel of the location of its robust futex list using
38.BR set_robust_list ().
39The address of a thread's robust futex list can be obtained using
40.BR get_robust_list ().
c6d039a3 41.P
34821bdd
MK
42The purpose of the robust futex list is to ensure that if a thread
43accidentally fails to unlock a futex before terminating or calling
44.BR execve (2),
45another thread that is waiting on that futex is notified that
46the former owner of the futex has died.
47This notification consists of two pieces: the
1ae6b2c7 48.B FUTEX_OWNER_DIED
34821bdd
MK
49bit is set in the futex word, and the kernel performs a
50.BR futex (2)
1ae6b2c7 51.B FUTEX_WAKE
34821bdd 52operation on one of the threads waiting on the futex.
c6d039a3 53.P
1f62bc9e 54The
ce50b4c3
MK
55.BR get_robust_list ()
56system call returns the head of the robust futex list of the thread
57whose thread ID is specified in
58.IR pid .
59If
60.I pid
61is 0,
62the head of the list for the calling thread is returned.
63The list head is stored in the location pointed to by
64.IR head_ptr .
65The size of the object pointed to by
66.I **head_ptr
67is stored in
68.IR len_ptr .
c6d039a3 69.P
a1c7ef56
MK
70Permission to employ
71.BR get_robust_list ()
72is governed by a ptrace access mode
73.B PTRACE_MODE_READ_REALCREDS
74check; see
75.BR ptrace (2).
c6d039a3 76.P
ce50b4c3
MK
77The
78.BR set_robust_list ()
79system call requests the kernel to record the head of the list of
80robust futexes owned by the calling thread.
81The
82.I head
83argument is the list head to record.
84The
1f62bc9e 85.I len
ce50b4c3
MK
86argument should be
87.IR sizeof(*head) .
47297adb 88.SH RETURN VALUE
1f62bc9e 89The
ce50b4c3 90.BR set_robust_list ()
0ab8aeec 91and
ce50b4c3
MK
92.BR get_robust_list ()
93system calls return zero when the operation is successful,
1f62bc9e 94an error code otherwise.
1f62bc9e
IV
95.SH ERRORS
96The
ce50b4c3 97.BR set_robust_list ()
99eccaa7 98system call can fail with the following error:
ce50b4c3 99.TP
0ab8aeec 100.B EINVAL
1f62bc9e 101.I len
c0a181aa
MK
102does not equal
103.IR "sizeof(struct\ robust_list_head)" .
c6d039a3 104.P
1f62bc9e 105The
ce50b4c3
MK
106.BR get_robust_list ()
107system call can fail with the following errors:
108.TP
49a2a105
MK
109.B EFAULT
110The head of the robust futex list can't be stored at the location
111.IR head .
112.TP
0ab8aeec 113.B EPERM
ce50b4c3
MK
114The calling process does not have permission to see the robust futex list of
115the thread with the thread ID
116.IR pid ,
117and does not have the
1ae6b2c7 118.B CAP_SYS_PTRACE
ce50b4c3
MK
119capability.
120.TP
0ab8aeec 121.B ESRCH
ce50b4c3 122No thread with the thread ID
1f62bc9e 123.I pid
ce50b4c3 124could be found.
ce50b4c3
MK
125.SH VERSIONS
126These system calls were added in Linux 2.6.17.
ce50b4c3
MK
127.SH NOTES
128These system calls are not needed by normal applications.
c6d039a3 129.P
ce50b4c3
MK
130A thread can have only one robust futex list;
131therefore applications that wish
132to use this functionality should use the robust mutexes provided by glibc.
c6d039a3 133.P
6e22a606
MK
134In the initial implementation,
135a thread waiting on a futex was notified that the owner had died
136only if the owner terminated.
137Starting with Linux 2.6.28,
138.\" commit 8141c7f3e7aee618312fa1c15109e1219de784a7
139notification was extended to include the case where the owner performs an
140.BR execve (2).
c6d039a3 141.P
30edf187
MK
142The thread IDs mentioned in the main text are
143.I kernel
144thread IDs of the kind returned by
145.BR clone (2)
146and
147.BR gettid (2).
47297adb 148.SH SEE ALSO
ad5722b3
MK
149.BR futex (2),
150.BR pthread_mutexattr_setrobust (3)
c6d039a3 151.P
1ae6b2c7 152.I Documentation/robust\-futexes.txt
ce50b4c3 153and
1ae6b2c7 154.I Documentation/robust\-futex\-ABI.txt
66a9882e 155in the Linux kernel source tree
ce50b4c3 156.\" http://lwn.net/Articles/172149/