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">
9 <title>sd_event_get_fd</title>
10 <productname>systemd</productname>
14 <refentrytitle>sd_event_get_fd</refentrytitle>
15 <manvolnum>3</manvolnum>
19 <refname>sd_event_get_fd</refname>
21 <refpurpose>Obtain a file descriptor to poll for event loop events</refpurpose>
26 <funcsynopsisinfo>#include <systemd/sd-event.h></funcsynopsisinfo>
29 <funcdef>int <function>sd_event_get_fd</function></funcdef>
30 <paramdef>sd_event *<parameter>event</parameter></paramdef>
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
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
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>
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>
67 <para>Returned errors may indicate the following problems:</para>
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>
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>
88 <title>Examples</title>
91 <title>Integration in the GLib event loop</title>
93 <programlisting><xi:include href="glib-event-glue.c" parse="text" /></programlisting>
97 <xi:include href="libsystemd-pkgconfig.xml" />
100 <title>History</title>
101 <para><function>sd_event_get_fd()</function> was added in version 217.</para>
105 <title>See Also</title>
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>