chiark / gitweb /
Drop my copyright headers
[elogind.git] / man / sd_event_get_fd.xml
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">
4
5 <!--
6   SPDX-License-Identifier: LGPL-2.1+
7 -->
8
9 <refentry id="sd_event_get_fd" xmlns:xi="http://www.w3.org/2001/XInclude">
10
11   <refentryinfo>
12     <title>sd_event_get_fd</title>
13     <productname>elogind</productname>
14
15     <authorgroup>
16       <author>
17         <contrib>More text</contrib>
18         <firstname>Zbigniew</firstname>
19         <surname>JÄ™drzejewski-Szmek</surname>
20         <email>zbyszek@in.waw.pl</email>
21       </author>
22     </authorgroup>
23   </refentryinfo>
24
25   <refmeta>
26     <refentrytitle>sd_event_get_fd</refentrytitle>
27     <manvolnum>3</manvolnum>
28   </refmeta>
29
30   <refnamediv>
31     <refname>sd_event_get_fd</refname>
32
33     <refpurpose>Obtain a file descriptor to poll for event loop events</refpurpose>
34   </refnamediv>
35
36   <refsynopsisdiv>
37     <funcsynopsis>
38       <funcsynopsisinfo>#include &lt;elogind/sd-event.h&gt;</funcsynopsisinfo>
39
40       <funcprototype>
41         <funcdef>int <function>sd_event_get_fd</function></funcdef>
42         <paramdef>sd_event *<parameter>event</parameter></paramdef>
43       </funcprototype>
44
45     </funcsynopsis>
46   </refsynopsisdiv>
47
48   <refsect1>
49     <title>Description</title>
50
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
55     be polled for
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>
60
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
64     <citerefentry
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>
68   </refsect1>
69
70   <refsect1>
71     <title>Return Value</title>
72
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>
76   </refsect1>
77
78   <refsect1>
79     <title>Errors</title>
80
81     <para>Returned errors may indicate the following problems:</para>
82
83     <variablelist>
84       <varlistentry>
85         <term><constant>-EINVAL</constant></term>
86
87         <listitem><para><parameter>event</parameter> is not a valid
88         pointer to an <structname>sd_event</structname> structure.
89         </para></listitem>
90       </varlistentry>
91
92       <varlistentry>
93         <term><constant>-ECHILD</constant></term>
94
95         <listitem><para>The event loop has been created in a different process.</para></listitem>
96
97       </varlistentry>
98     </variablelist>
99   </refsect1>
100
101   <refsect1>
102     <title>Examples</title>
103
104     <example>
105       <title>Integration in the GLib event loop</title>
106
107       <programlisting><xi:include href="glib-event-glue.c" parse="text" /></programlisting>
108     </example>
109   </refsect1>
110
111   <xi:include href="libelogind-pkgconfig.xml" />
112
113   <refsect1>
114     <title>See Also</title>
115
116     <para>
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>
122     </para>
123   </refsect1>
124
125 </refentry>