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 <contrib>More text</contrib>
18 <firstname>Zbigniew</firstname>
19 <surname>Jędrzejewski-Szmek</surname>
20 <email>zbyszek@in.waw.pl</email>
26 <refentrytitle>sd_event_get_fd</refentrytitle>
27 <manvolnum>3</manvolnum>
31 <refname>sd_event_get_fd</refname>
33 <refpurpose>Obtain a file descriptor to poll for event loop events</refpurpose>
38 <funcsynopsisinfo>#include <elogind/sd-event.h></funcsynopsisinfo>
41 <funcdef>int <function>sd_event_get_fd</function></funcdef>
42 <paramdef>sd_event *<parameter>event</parameter></paramdef>
49 <title>Description</title>
51 <para><function>sd_event_get_fd()</function> returns the file
52 descriptor that an event loop object returned by the
53 <citerefentry><refentrytitle>sd_event_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>
54 function uses to wait for events. This file descriptor may itself
56 <constant>POLLIN</constant>/<constant>EPOLLIN</constant>
57 events. This makes it possible to embed an
58 <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>
59 event loop into another, possibly foreign, event loop.</para>
61 <para>The returned file descriptor refers to an <citerefentry
62 project='man-pages'><refentrytitle>epoll</refentrytitle><manvolnum>7</manvolnum></citerefentry>
63 object. It is recommended not to alter it by invoking
65 project='man-pages'><refentrytitle>epoll_ctl</refentrytitle><manvolnum>2</manvolnum></citerefentry>
66 on it, in order to avoid interference with the event loop's inner
67 logic and assumptions.</para>
71 <title>Return Value</title>
73 <para>On success, <function>sd_event_get_fd()</function> returns a
74 non-negative file descriptor. On failure, it returns a negative
75 errno-style error code.</para>
81 <para>Returned errors may indicate the following problems:</para>
85 <term><constant>-EINVAL</constant></term>
87 <listitem><para><parameter>event</parameter> is not a valid
88 pointer to an <structname>sd_event</structname> structure.
93 <term><constant>-ECHILD</constant></term>
95 <listitem><para>The event loop has been created in a different process.</para></listitem>
102 <title>Examples</title>
105 <title>Integration in the GLib event loop</title>
107 <programlisting><xi:include href="glib-event-glue.c" parse="text" /></programlisting>
111 <xi:include href="libelogind-pkgconfig.xml" />
114 <title>See Also</title>
117 <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
118 <citerefentry><refentrytitle>sd_event_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
119 <citerefentry><refentrytitle>sd_event_wait</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
120 <citerefentry project='man-pages'><refentrytitle>epoll_ctl</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
121 <citerefentry project='man-pages'><refentrytitle>epoll</refentrytitle><manvolnum>7</manvolnum></citerefentry>