1:255.13-alt1
[systemd_ALT.git] / man / sd_event_get_fd.xml
blobe68b688aff69f277a55e2a72519df85c0829ebaf
1 <?xml version='1.0'?>
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3   "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
6 <refentry id="sd_event_get_fd" xmlns:xi="http://www.w3.org/2001/XInclude">
8   <refentryinfo>
9     <title>sd_event_get_fd</title>
10     <productname>systemd</productname>
11   </refentryinfo>
13   <refmeta>
14     <refentrytitle>sd_event_get_fd</refentrytitle>
15     <manvolnum>3</manvolnum>
16   </refmeta>
18   <refnamediv>
19     <refname>sd_event_get_fd</refname>
21     <refpurpose>Obtain a file descriptor to poll for event loop events</refpurpose>
22   </refnamediv>
24   <refsynopsisdiv>
25     <funcsynopsis>
26       <funcsynopsisinfo>#include &lt;systemd/sd-event.h&gt;</funcsynopsisinfo>
28       <funcprototype>
29         <funcdef>int <function>sd_event_get_fd</function></funcdef>
30         <paramdef>sd_event *<parameter>event</parameter></paramdef>
31       </funcprototype>
33     </funcsynopsis>
34   </refsynopsisdiv>
36   <refsect1>
37     <title>Description</title>
39     <para><function>sd_event_get_fd()</function> returns the file
40     descriptor that an event loop object returned by the
41     <citerefentry><refentrytitle>sd_event_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>
42     function uses to wait for events. This file descriptor may itself
43     be polled for
44     <constant>POLLIN</constant>/<constant>EPOLLIN</constant>
45     events. This makes it possible to embed an
46     <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>
47     event loop into another, possibly foreign, event loop.</para>
49     <para>The returned file descriptor refers to an <citerefentry
50     project='man-pages'><refentrytitle>epoll</refentrytitle><manvolnum>7</manvolnum></citerefentry>
51     object. It is recommended not to alter it by invoking
52     <citerefentry
53     project='man-pages'><refentrytitle>epoll_ctl</refentrytitle><manvolnum>2</manvolnum></citerefentry>
54     on it, in order to avoid interference with the event loop's inner
55     logic and assumptions.</para>
56   </refsect1>
58   <refsect1>
59     <title>Return Value</title>
61     <para>On success, <function>sd_event_get_fd()</function> returns a non-negative file descriptor. On
62     failure, it returns a negative errno-style error code.</para>
64     <refsect2>
65       <title>Errors</title>
67       <para>Returned errors may indicate the following problems:</para>
69       <variablelist>
70         <varlistentry>
71           <term><constant>-EINVAL</constant></term>
73           <listitem><para><parameter>event</parameter> is not a valid pointer to an
74           <structname>sd_event</structname> structure.</para></listitem>
75         </varlistentry>
77         <varlistentry>
78           <term><constant>-ECHILD</constant></term>
80           <listitem><para>The event loop has been created in a different process, library or module instance.</para></listitem>
82         </varlistentry>
83       </variablelist>
84     </refsect2>
85   </refsect1>
87   <refsect1>
88     <title>Examples</title>
90     <example>
91       <title>Integration in the GLib event loop</title>
93       <programlisting><xi:include href="glib-event-glue.c" parse="text" /></programlisting>
94     </example>
95   </refsect1>
97   <xi:include href="libsystemd-pkgconfig.xml" />
99   <refsect1>
100     <title>History</title>
101     <para><function>sd_event_get_fd()</function> was added in version 217.</para>
102   </refsect1>
104   <refsect1>
105     <title>See Also</title>
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>2</manvolnum></citerefentry>,
112       <citerefentry project='man-pages'><refentrytitle>epoll</refentrytitle><manvolnum>7</manvolnum></citerefentry>
113     </para>
114   </refsect1>
116 </refentry>