chiark / gitweb /
man: add missing headers to glib-event-glue.c
[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   This file is part of elogind.
7   SPDX-License-Identifier: LGPL-2.1+
8
9
10   Copyright 2014 Zbigniew JÄ™drzejewski-Szmek
11
12   elogind 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.
16
17   elogind 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.
21
22   You should have received a copy of the GNU Lesser General Public License
23   along with elogind; If not, see <http://www.gnu.org/licenses/>.
24 -->
25
26 <refentry id="sd_event_get_fd" xmlns:xi="http://www.w3.org/2001/XInclude">
27
28   <refentryinfo>
29     <title>sd_event_get_fd</title>
30     <productname>elogind</productname>
31
32     <authorgroup>
33       <author>
34         <contrib>More text</contrib>
35         <firstname>Zbigniew</firstname>
36         <surname>JÄ™drzejewski-Szmek</surname>
37         <email>zbyszek@in.waw.pl</email>
38       </author>
39     </authorgroup>
40   </refentryinfo>
41
42   <refmeta>
43     <refentrytitle>sd_event_get_fd</refentrytitle>
44     <manvolnum>3</manvolnum>
45   </refmeta>
46
47   <refnamediv>
48     <refname>sd_event_get_fd</refname>
49
50     <refpurpose>Obtain a file descriptor to poll for event loop events</refpurpose>
51   </refnamediv>
52
53   <refsynopsisdiv>
54     <funcsynopsis>
55       <funcsynopsisinfo>#include &lt;elogind/sd-event.h&gt;</funcsynopsisinfo>
56
57       <funcprototype>
58         <funcdef>int <function>sd_event_get_fd</function></funcdef>
59         <paramdef>sd_event *<parameter>event</parameter></paramdef>
60       </funcprototype>
61
62     </funcsynopsis>
63   </refsynopsisdiv>
64
65   <refsect1>
66     <title>Description</title>
67
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
72     be polled for
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>
77
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
81     <citerefentry
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>
85   </refsect1>
86
87   <refsect1>
88     <title>Return Value</title>
89
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>
93   </refsect1>
94
95   <refsect1>
96     <title>Errors</title>
97
98     <para>Returned errors may indicate the following problems:</para>
99
100     <variablelist>
101       <varlistentry>
102         <term><constant>-EINVAL</constant></term>
103
104         <listitem><para><parameter>event</parameter> is not a valid
105         pointer to an <structname>sd_event</structname> structure.
106         </para></listitem>
107       </varlistentry>
108
109       <varlistentry>
110         <term><constant>-ECHILD</constant></term>
111
112         <listitem><para>The event loop has been created in a different process.</para></listitem>
113
114       </varlistentry>
115     </variablelist>
116   </refsect1>
117
118   <refsect1>
119     <title>Examples</title>
120
121     <example>
122       <title>Integration in the GLib event loop</title>
123
124       <programlisting><xi:include href="glib-event-glue.c" parse="text" /></programlisting>
125     </example>
126   </refsect1>
127
128   <xi:include href="libelogind-pkgconfig.xml" />
129
130   <refsect1>
131     <title>See Also</title>
132
133     <para>
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>
139     </para>
140   </refsect1>
141
142 </refentry>