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 This file is part of systemd.
10 Copyright 2014 Zbigniew Jędrzejewski-Szmek
12 systemd is free software; you can redistribute it and/or modify it
13 under the terms of the GNU Lesser General Public License as published by
14 the Free Software Foundation; either version 2.1 of the License, or
15 (at your option) any later version.
17 systemd is distributed in the hope that it will be useful, but
18 WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 Lesser General Public License for more details.
22 You should have received a copy of the GNU Lesser General Public License
23 along with systemd; If not, see <http://www.gnu.org/licenses/>.
26 <refentry id=
"sd_event_get_fd" xmlns:
xi=
"http://www.w3.org/2001/XInclude">
29 <title>sd_event_get_fd
</title>
30 <productname>systemd
</productname>
34 <contrib>More text
</contrib>
35 <firstname>Zbigniew
</firstname>
36 <surname>Jędrzejewski-Szmek
</surname>
37 <email>zbyszek@in.waw.pl
</email>
43 <refentrytitle>sd_event_get_fd
</refentrytitle>
44 <manvolnum>3</manvolnum>
48 <refname>sd_event_get_fd
</refname>
50 <refpurpose>Obtain a file descriptor to poll for event loop events
</refpurpose>
55 <funcsynopsisinfo>#include
<systemd/sd-event.h
></funcsynopsisinfo>
58 <funcdef>int
<function>sd_event_get_fd
</function></funcdef>
59 <paramdef>sd_event *
<parameter>event
</parameter></paramdef>
66 <title>Description
</title>
68 <para><function>sd_event_get_fd()
</function> returns the file
69 descriptor that an event loop object returned by the
70 <citerefentry><refentrytitle>sd_event_new
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
71 function uses to wait for events. This file descriptor may itself
73 <constant>POLLIN
</constant>/
<constant>EPOLLIN
</constant>
74 events. This makes it possible to embed an
75 <citerefentry><refentrytitle>sd-event
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
76 event loop into another, possibly foreign, event loop.
</para>
78 <para>The returned file descriptor refers to an
<citerefentry
79 project='man-pages'
><refentrytitle>epoll
</refentrytitle><manvolnum>7</manvolnum></citerefentry>
80 object. It is recommended not to alter it by invoking
82 project='man-pages'
><refentrytitle>epoll_ctl
</refentrytitle><manvolnum>2</manvolnum></citerefentry>
83 on it, in order to avoid interference with the event loop's inner
84 logic and assumptions.
</para>
88 <title>Return Value
</title>
90 <para>On success,
<function>sd_event_get_fd()
</function> returns a
91 non-negative file descriptor. On failure, it returns a negative
92 errno-style error code.
</para>
98 <para>Returned errors may indicate the following problems:
</para>
102 <term><constant>-EINVAL
</constant></term>
104 <listitem><para><parameter>event
</parameter> is not a valid
105 pointer to an
<structname>sd_event
</structname> structure.
110 <term><constant>-ECHILD
</constant></term>
112 <listitem><para>The event loop has been created in a different process.
</para></listitem>
119 <title>Examples
</title>
122 <title>Integration in the GLib event loop
</title>
124 <programlisting><xi:include href=
"glib-event-glue.c" parse=
"text" /></programlisting>
128 <xi:include href=
"libsystemd-pkgconfig.xml" />
131 <title>See Also
</title>
134 <citerefentry><refentrytitle>sd-event
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
135 <citerefentry><refentrytitle>sd_event_new
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
136 <citerefentry><refentrytitle>sd_event_wait
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
137 <citerefentry project='man-pages'
><refentrytitle>epoll_ctl
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
138 <citerefentry project='man-pages'
><refentrytitle>epoll
</refentrytitle><manvolnum>7</manvolnum></citerefentry>