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+
8 Copyright © 2014 Zbigniew Jędrzejewski-Szmek
11 <refentry id="sd_event_get_fd" xmlns:xi="http://www.w3.org/2001/XInclude">
14 <title>sd_event_get_fd</title>
15 <productname>elogind</productname>
19 <contrib>More text</contrib>
20 <firstname>Zbigniew</firstname>
21 <surname>Jędrzejewski-Szmek</surname>
22 <email>zbyszek@in.waw.pl</email>
28 <refentrytitle>sd_event_get_fd</refentrytitle>
29 <manvolnum>3</manvolnum>
33 <refname>sd_event_get_fd</refname>
35 <refpurpose>Obtain a file descriptor to poll for event loop events</refpurpose>
40 <funcsynopsisinfo>#include <elogind/sd-event.h></funcsynopsisinfo>
43 <funcdef>int <function>sd_event_get_fd</function></funcdef>
44 <paramdef>sd_event *<parameter>event</parameter></paramdef>
51 <title>Description</title>
53 <para><function>sd_event_get_fd()</function> returns the file
54 descriptor that an event loop object returned by the
55 <citerefentry><refentrytitle>sd_event_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>
56 function uses to wait for events. This file descriptor may itself
58 <constant>POLLIN</constant>/<constant>EPOLLIN</constant>
59 events. This makes it possible to embed an
60 <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>
61 event loop into another, possibly foreign, event loop.</para>
63 <para>The returned file descriptor refers to an <citerefentry
64 project='man-pages'><refentrytitle>epoll</refentrytitle><manvolnum>7</manvolnum></citerefentry>
65 object. It is recommended not to alter it by invoking
67 project='man-pages'><refentrytitle>epoll_ctl</refentrytitle><manvolnum>2</manvolnum></citerefentry>
68 on it, in order to avoid interference with the event loop's inner
69 logic and assumptions.</para>
73 <title>Return Value</title>
75 <para>On success, <function>sd_event_get_fd()</function> returns a
76 non-negative file descriptor. On failure, it returns a negative
77 errno-style error code.</para>
83 <para>Returned errors may indicate the following problems:</para>
87 <term><constant>-EINVAL</constant></term>
89 <listitem><para><parameter>event</parameter> is not a valid
90 pointer to an <structname>sd_event</structname> structure.
95 <term><constant>-ECHILD</constant></term>
97 <listitem><para>The event loop has been created in a different process.</para></listitem>
104 <title>Examples</title>
107 <title>Integration in the GLib event loop</title>
109 <programlisting><xi:include href="glib-event-glue.c" parse="text" /></programlisting>
113 <xi:include href="libelogind-pkgconfig.xml" />
116 <title>See Also</title>
119 <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
120 <citerefentry><refentrytitle>sd_event_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
121 <citerefentry><refentrytitle>sd_event_wait</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
122 <citerefentry project='man-pages'><refentrytitle>epoll_ctl</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
123 <citerefentry project='man-pages'><refentrytitle>epoll</refentrytitle><manvolnum>7</manvolnum></citerefentry>