man-pages/man2/get_robust_list.2.html
2021-03-31 01:06:50 +01:00

259 lines
6.0 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of GET_ROBUST_LIST</TITLE>
</HEAD><BODY>
<H1>GET_ROBUST_LIST</H1>
Section: Linux System Calls (2)<BR>Updated: 2019-10-10<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
get_robust_list, set_robust_list - get/set list of robust futexes
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<PRE>
<B>#include &lt;<A HREF="file:///usr/include/linux/futex.h">linux/futex.h</A>&gt;</B>
<B>#include &lt;<A HREF="file:///usr/include/sys/types.h">sys/types.h</A>&gt;</B>
<B>#include &lt;<A HREF="file:///usr/include/syscall.h">syscall.h</A>&gt;</B>
<B>long get_robust_list(int </B><I>pid</I><B>, struct robust_list_head **</B><I>head_ptr</I><B>,</B>
<B> size_t *</B><I>len_ptr</I><B>);</B>
<B>long set_robust_list(struct robust_list_head *</B><I>head</I><B>, size_t </B><I>len</I><B>);</B>
</PRE>
<P>
<I>Note</I>:
There are no glibc wrappers for these system calls; see NOTES.
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
These system calls deal with per-thread robust futex lists.
These lists are managed in user space:
the kernel knows only about the location of the head of the list.
A thread can inform the kernel of the location of its robust futex list using
<B>set_robust_list</B>().
The address of a thread's robust futex list can be obtained using
<B>get_robust_list</B>().
<P>
The purpose of the robust futex list is to ensure that if a thread
accidentally fails to unlock a futex before terminating or calling
<B><A HREF="/cgi-bin/man/man2html?2+execve">execve</A></B>(2),
another thread that is waiting on that futex is notified that
the former owner of the futex has died.
This notification consists of two pieces: the
<B>FUTEX_OWNER_DIED</B>
bit is set in the futex word, and the kernel performs a
<B><A HREF="/cgi-bin/man/man2html?2+futex">futex</A></B>(2)
<B>FUTEX_WAKE</B>
operation on one of the threads waiting on the futex.
<P>
The
<B>get_robust_list</B>()
system call returns the head of the robust futex list of the thread
whose thread ID is specified in
<I>pid</I>.
If
<I>pid</I>
is 0,
the head of the list for the calling thread is returned.
The list head is stored in the location pointed to by
<I>head_ptr</I>.
The size of the object pointed to by
<I>**head_ptr</I>
is stored in
<I>len_ptr</I>.
<P>
Permission to employ
<B>get_robust_list</B>()
is governed by a ptrace access mode
<B>PTRACE_MODE_READ_REALCREDS</B>
check; see
<B><A HREF="/cgi-bin/man/man2html?2+ptrace">ptrace</A></B>(2).
<P>
The
<B>set_robust_list</B>()
system call requests the kernel to record the head of the list of
robust futexes owned by the calling thread.
The
<I>head</I>
argument is the list head to record.
The
<I>len</I>
argument should be
<I>sizeof(*head)</I>.
<A NAME="lbAE">&nbsp;</A>
<H2>RETURN VALUE</H2>
The
<B>set_robust_list</B>()
and
<B>get_robust_list</B>()
system calls return zero when the operation is successful,
an error code otherwise.
<A NAME="lbAF">&nbsp;</A>
<H2>ERRORS</H2>
The
<B>set_robust_list</B>()
system call can fail with the following error:
<DL COMPACT>
<DT id="1"><B>EINVAL</B>
<DD>
<I>len</I>
does not equal
<I>sizeof(struct&nbsp;robust_list_head)</I>.
</DL>
<P>
The
<B>get_robust_list</B>()
system call can fail with the following errors:
<DL COMPACT>
<DT id="2"><B>EFAULT</B>
<DD>
The head of the robust futex list can't be stored at the location
<I>head</I>.
<DT id="3"><B>EPERM</B>
<DD>
The calling process does not have permission to see the robust futex list of
the thread with the thread ID
<I>pid</I>,
and does not have the
<B>CAP_SYS_PTRACE</B>
capability.
<DT id="4"><B>ESRCH</B>
<DD>
No thread with the thread ID
<I>pid</I>
could be found.
</DL>
<A NAME="lbAG">&nbsp;</A>
<H2>VERSIONS</H2>
These system calls were added in Linux 2.6.17.
<A NAME="lbAH">&nbsp;</A>
<H2>NOTES</H2>
These system calls are not needed by normal applications.
No support for them is provided in glibc.
In the unlikely event that you want to call them directly, use
<B><A HREF="/cgi-bin/man/man2html?2+syscall">syscall</A></B>(2).
<P>
A thread can have only one robust futex list;
therefore applications that wish
to use this functionality should use the robust mutexes provided by glibc.
<P>
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,
notification was extended to include the case where the owner performs an
<B><A HREF="/cgi-bin/man/man2html?2+execve">execve</A></B>(2).
<P>
The thread IDs mentioned in the main text are
<I>kernel</I>
thread IDs of the kind returned by
<B><A HREF="/cgi-bin/man/man2html?2+clone">clone</A></B>(2)
and
<B><A HREF="/cgi-bin/man/man2html?2+gettid">gettid</A></B>(2).
<A NAME="lbAI">&nbsp;</A>
<H2>SEE ALSO</H2>
<B><A HREF="/cgi-bin/man/man2html?2+futex">futex</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?3+pthread_mutexattr_setrobust">pthread_mutexattr_setrobust</A></B>(3)
<P>
<I>Documentation/robust-futexes.txt</I>
and
<I>Documentation/robust-futex-ABI.txt</I>
in the Linux kernel source tree
<A NAME="lbAJ">&nbsp;</A>
<H2>COLOPHON</H2>
This page is part of release 5.05 of the Linux
<I>man-pages</I>
project.
A description of the project,
information about reporting bugs,
and the latest version of this page,
can be found at
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="5"><A HREF="#lbAB">NAME</A><DD>
<DT id="6"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="7"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="8"><A HREF="#lbAE">RETURN VALUE</A><DD>
<DT id="9"><A HREF="#lbAF">ERRORS</A><DD>
<DT id="10"><A HREF="#lbAG">VERSIONS</A><DD>
<DT id="11"><A HREF="#lbAH">NOTES</A><DD>
<DT id="12"><A HREF="#lbAI">SEE ALSO</A><DD>
<DT id="13"><A HREF="#lbAJ">COLOPHON</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:32 GMT, March 31, 2021
</BODY>
</HTML>