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 <refentrytitle>sd_event_get_fd</refentrytitle>
20 <manvolnum>3</manvolnum>
24 <refname>sd_event_get_fd</refname>
26 <refpurpose>Obtain a file descriptor to poll for event loop events</refpurpose>
31 <funcsynopsisinfo>#include <elogind/sd-event.h></funcsynopsisinfo>
34 <funcdef>int <function>sd_event_get_fd</function></funcdef>
35 <paramdef>sd_event *<parameter>event</parameter></paramdef>
42 <title>Description</title>
44 <para><function>sd_event_get_fd()</function> returns the file
45 descriptor that an event loop object returned by the
46 <citerefentry><refentrytitle>sd_event_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>
47 function uses to wait for events. This file descriptor may itself
49 <constant>POLLIN</constant>/<constant>EPOLLIN</constant>
50 events. This makes it possible to embed an
51 <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>
52 event loop into another, possibly foreign, event loop.</para>
54 <para>The returned file descriptor refers to an <citerefentry
55 project='man-pages'><refentrytitle>epoll</refentrytitle><manvolnum>7</manvolnum></citerefentry>
56 object. It is recommended not to alter it by invoking
58 project='man-pages'><refentrytitle>epoll_ctl</refentrytitle><manvolnum>2</manvolnum></citerefentry>
59 on it, in order to avoid interference with the event loop's inner
60 logic and assumptions.</para>
64 <title>Return Value</title>
66 <para>On success, <function>sd_event_get_fd()</function> returns a
67 non-negative file descriptor. On failure, it returns a negative
68 errno-style error code.</para>
74 <para>Returned errors may indicate the following problems:</para>
78 <term><constant>-EINVAL</constant></term>
80 <listitem><para><parameter>event</parameter> is not a valid
81 pointer to an <structname>sd_event</structname> structure.
86 <term><constant>-ECHILD</constant></term>
88 <listitem><para>The event loop has been created in a different process.</para></listitem>
95 <title>Examples</title>
98 <title>Integration in the GLib event loop</title>
100 <programlisting><xi:include href="glib-event-glue.c" parse="text" /></programlisting>
104 <xi:include href="libelogind-pkgconfig.xml" />
107 <title>See Also</title>
110 <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
111 <citerefentry><refentrytitle>sd_event_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
112 <citerefentry><refentrytitle>sd_event_wait</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
113 <citerefentry project='man-pages'><refentrytitle>epoll_ctl</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
114 <citerefentry project='man-pages'><refentrytitle>epoll</refentrytitle><manvolnum>7</manvolnum></citerefentry>