chiark / gitweb /
Prep v239: Add missing updates that evaded migration.
[elogind.git] / man / sd_event_get_fd.xml
1 <?xml version='1.0'?> <!--*- Mode: nxml; nxml-child-indent: 2; indent-tabs-mode: nil -*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4
5 <!--
6   SPDX-License-Identifier: LGPL-2.1+
7 -->
8
9 <refentry id="sd_event_get_fd" xmlns:xi="http://www.w3.org/2001/XInclude">
10
11   <refentryinfo>
12     <title>sd_event_get_fd</title>
13     <productname>elogind</productname>
14   </refentryinfo>
15
16   <refmeta>
17     <refentrytitle>sd_event_get_fd</refentrytitle>
18     <manvolnum>3</manvolnum>
19   </refmeta>
20
21   <refnamediv>
22     <refname>sd_event_get_fd</refname>
23
24     <refpurpose>Obtain a file descriptor to poll for event loop events</refpurpose>
25   </refnamediv>
26
27   <refsynopsisdiv>
28     <funcsynopsis>
29       <funcsynopsisinfo>#include &lt;elogind/sd-event.h&gt;</funcsynopsisinfo>
30
31       <funcprototype>
32         <funcdef>int <function>sd_event_get_fd</function></funcdef>
33         <paramdef>sd_event *<parameter>event</parameter></paramdef>
34       </funcprototype>
35
36     </funcsynopsis>
37   </refsynopsisdiv>
38
39   <refsect1>
40     <title>Description</title>
41
42     <para><function>sd_event_get_fd()</function> returns the file
43     descriptor that an event loop object returned by the
44     <citerefentry><refentrytitle>sd_event_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>
45     function uses to wait for events. This file descriptor may itself
46     be polled for
47     <constant>POLLIN</constant>/<constant>EPOLLIN</constant>
48     events. This makes it possible to embed an
49     <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>
50     event loop into another, possibly foreign, event loop.</para>
51
52     <para>The returned file descriptor refers to an <citerefentry
53     project='man-pages'><refentrytitle>epoll</refentrytitle><manvolnum>7</manvolnum></citerefentry>
54     object. It is recommended not to alter it by invoking
55     <citerefentry
56     project='man-pages'><refentrytitle>epoll_ctl</refentrytitle><manvolnum>2</manvolnum></citerefentry>
57     on it, in order to avoid interference with the event loop's inner
58     logic and assumptions.</para>
59   </refsect1>
60
61   <refsect1>
62     <title>Return Value</title>
63
64     <para>On success, <function>sd_event_get_fd()</function> returns a
65     non-negative file descriptor. On failure, it returns a negative
66     errno-style error code.</para>
67   </refsect1>
68
69   <refsect1>
70     <title>Errors</title>
71
72     <para>Returned errors may indicate the following problems:</para>
73
74     <variablelist>
75       <varlistentry>
76         <term><constant>-EINVAL</constant></term>
77
78         <listitem><para><parameter>event</parameter> is not a valid
79         pointer to an <structname>sd_event</structname> structure.
80         </para></listitem>
81       </varlistentry>
82
83       <varlistentry>
84         <term><constant>-ECHILD</constant></term>
85
86         <listitem><para>The event loop has been created in a different process.</para></listitem>
87
88       </varlistentry>
89     </variablelist>
90   </refsect1>
91
92   <refsect1>
93     <title>Examples</title>
94
95     <example>
96       <title>Integration in the GLib event loop</title>
97
98       <programlisting><xi:include href="glib-event-glue.c" parse="text" /></programlisting>
99     </example>
100   </refsect1>
101
102   <xi:include href="libelogind-pkgconfig.xml" />
103
104   <refsect1>
105     <title>See Also</title>
106
107     <para>
108       <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
109       <citerefentry><refentrytitle>sd_event_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
110       <citerefentry><refentrytitle>sd_event_wait</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
111       <citerefentry project='man-pages'><refentrytitle>epoll_ctl</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
112       <citerefentry project='man-pages'><refentrytitle>epoll</refentrytitle><manvolnum>7</manvolnum></citerefentry>
113     </para>
114   </refsect1>
115
116 </refentry>