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">
6 SPDX-License-Identifier: LGPL-2.1+
9 <refentry id="sd_event_get_fd" xmlns:xi="http://www.w3.org/2001/XInclude">
12 <title>sd_event_get_fd</title>
13 <productname>elogind</productname>
17 <refentrytitle>sd_event_get_fd</refentrytitle>
18 <manvolnum>3</manvolnum>
22 <refname>sd_event_get_fd</refname>
24 <refpurpose>Obtain a file descriptor to poll for event loop events</refpurpose>
29 <funcsynopsisinfo>#include <elogind/sd-event.h></funcsynopsisinfo>
32 <funcdef>int <function>sd_event_get_fd</function></funcdef>
33 <paramdef>sd_event *<parameter>event</parameter></paramdef>
40 <title>Description</title>
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
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>
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
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>
62 <title>Return Value</title>
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>
72 <para>Returned errors may indicate the following problems:</para>
76 <term><constant>-EINVAL</constant></term>
78 <listitem><para><parameter>event</parameter> is not a valid
79 pointer to an <structname>sd_event</structname> structure.
84 <term><constant>-ECHILD</constant></term>
86 <listitem><para>The event loop has been created in a different process.</para></listitem>
93 <title>Examples</title>
96 <title>Integration in the GLib event loop</title>
98 <programlisting><xi:include href="glib-event-glue.c" parse="text" /></programlisting>
102 <xi:include href="libelogind-pkgconfig.xml" />
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>3</manvolnum></citerefentry>,
112 <citerefentry project='man-pages'><refentrytitle>epoll</refentrytitle><manvolnum>7</manvolnum></citerefentry>