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 This file is part of elogind.
7 SPDX-License-Identifier: LGPL-2.1+
10 Copyright 2014 Zbigniew Jędrzejewski-Szmek
13 <refentry id="sd_event_get_fd" xmlns:xi="http://www.w3.org/2001/XInclude">
16 <title>sd_event_get_fd</title>
17 <productname>elogind</productname>
21 <contrib>More text</contrib>
22 <firstname>Zbigniew</firstname>
23 <surname>Jędrzejewski-Szmek</surname>
24 <email>zbyszek@in.waw.pl</email>
30 <refentrytitle>sd_event_get_fd</refentrytitle>
31 <manvolnum>3</manvolnum>
35 <refname>sd_event_get_fd</refname>
37 <refpurpose>Obtain a file descriptor to poll for event loop events</refpurpose>
42 <funcsynopsisinfo>#include <elogind/sd-event.h></funcsynopsisinfo>
45 <funcdef>int <function>sd_event_get_fd</function></funcdef>
46 <paramdef>sd_event *<parameter>event</parameter></paramdef>
53 <title>Description</title>
55 <para><function>sd_event_get_fd()</function> returns the file
56 descriptor that an event loop object returned by the
57 <citerefentry><refentrytitle>sd_event_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>
58 function uses to wait for events. This file descriptor may itself
60 <constant>POLLIN</constant>/<constant>EPOLLIN</constant>
61 events. This makes it possible to embed an
62 <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>
63 event loop into another, possibly foreign, event loop.</para>
65 <para>The returned file descriptor refers to an <citerefentry
66 project='man-pages'><refentrytitle>epoll</refentrytitle><manvolnum>7</manvolnum></citerefentry>
67 object. It is recommended not to alter it by invoking
69 project='man-pages'><refentrytitle>epoll_ctl</refentrytitle><manvolnum>2</manvolnum></citerefentry>
70 on it, in order to avoid interference with the event loop's inner
71 logic and assumptions.</para>
75 <title>Return Value</title>
77 <para>On success, <function>sd_event_get_fd()</function> returns a
78 non-negative file descriptor. On failure, it returns a negative
79 errno-style error code.</para>
85 <para>Returned errors may indicate the following problems:</para>
89 <term><constant>-EINVAL</constant></term>
91 <listitem><para><parameter>event</parameter> is not a valid
92 pointer to an <structname>sd_event</structname> structure.
97 <term><constant>-ECHILD</constant></term>
99 <listitem><para>The event loop has been created in a different process.</para></listitem>
106 <title>Examples</title>
109 <title>Integration in the GLib event loop</title>
111 <programlisting><xi:include href="glib-event-glue.c" parse="text" /></programlisting>
115 <xi:include href="libelogind-pkgconfig.xml" />
118 <title>See Also</title>
121 <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
122 <citerefentry><refentrytitle>sd_event_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
123 <citerefentry><refentrytitle>sd_event_wait</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
124 <citerefentry project='man-pages'><refentrytitle>epoll_ctl</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
125 <citerefentry project='man-pages'><refentrytitle>epoll</refentrytitle><manvolnum>7</manvolnum></citerefentry>