chiark / gitweb /
tree-wide: beautify remaining copyright statements
[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   Copyright © 2014 Zbigniew Jędrzejewski-Szmek
9 -->
10
11 <refentry id="sd_event_get_fd" xmlns:xi="http://www.w3.org/2001/XInclude">
12
13   <refentryinfo>
14     <title>sd_event_get_fd</title>
15     <productname>elogind</productname>
16
17     <authorgroup>
18       <author>
19         <contrib>More text</contrib>
20         <firstname>Zbigniew</firstname>
21         <surname>Jędrzejewski-Szmek</surname>
22         <email>zbyszek@in.waw.pl</email>
23       </author>
24     </authorgroup>
25   </refentryinfo>
26
27   <refmeta>
28     <refentrytitle>sd_event_get_fd</refentrytitle>
29     <manvolnum>3</manvolnum>
30   </refmeta>
31
32   <refnamediv>
33     <refname>sd_event_get_fd</refname>
34
35     <refpurpose>Obtain a file descriptor to poll for event loop events</refpurpose>
36   </refnamediv>
37
38   <refsynopsisdiv>
39     <funcsynopsis>
40       <funcsynopsisinfo>#include &lt;elogind/sd-event.h&gt;</funcsynopsisinfo>
41
42       <funcprototype>
43         <funcdef>int <function>sd_event_get_fd</function></funcdef>
44         <paramdef>sd_event *<parameter>event</parameter></paramdef>
45       </funcprototype>
46
47     </funcsynopsis>
48   </refsynopsisdiv>
49
50   <refsect1>
51     <title>Description</title>
52
53     <para><function>sd_event_get_fd()</function> returns the file
54     descriptor that an event loop object returned by the
55     <citerefentry><refentrytitle>sd_event_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>
56     function uses to wait for events. This file descriptor may itself
57     be polled for
58     <constant>POLLIN</constant>/<constant>EPOLLIN</constant>
59     events. This makes it possible to embed an
60     <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>
61     event loop into another, possibly foreign, event loop.</para>
62
63     <para>The returned file descriptor refers to an <citerefentry
64     project='man-pages'><refentrytitle>epoll</refentrytitle><manvolnum>7</manvolnum></citerefentry>
65     object. It is recommended not to alter it by invoking
66     <citerefentry
67     project='man-pages'><refentrytitle>epoll_ctl</refentrytitle><manvolnum>2</manvolnum></citerefentry>
68     on it, in order to avoid interference with the event loop's inner
69     logic and assumptions.</para>
70   </refsect1>
71
72   <refsect1>
73     <title>Return Value</title>
74
75     <para>On success, <function>sd_event_get_fd()</function> returns a
76     non-negative file descriptor. On failure, it returns a negative
77     errno-style error code.</para>
78   </refsect1>
79
80   <refsect1>
81     <title>Errors</title>
82
83     <para>Returned errors may indicate the following problems:</para>
84
85     <variablelist>
86       <varlistentry>
87         <term><constant>-EINVAL</constant></term>
88
89         <listitem><para><parameter>event</parameter> is not a valid
90         pointer to an <structname>sd_event</structname> structure.
91         </para></listitem>
92       </varlistentry>
93
94       <varlistentry>
95         <term><constant>-ECHILD</constant></term>
96
97         <listitem><para>The event loop has been created in a different process.</para></listitem>
98
99       </varlistentry>
100     </variablelist>
101   </refsect1>
102
103   <refsect1>
104     <title>Examples</title>
105
106     <example>
107       <title>Integration in the GLib event loop</title>
108
109       <programlisting><xi:include href="glib-event-glue.c" parse="text" /></programlisting>
110     </example>
111   </refsect1>
112
113   <xi:include href="libelogind-pkgconfig.xml" />
114
115   <refsect1>
116     <title>See Also</title>
117
118     <para>
119       <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
120       <citerefentry><refentrytitle>sd_event_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
121       <citerefentry><refentrytitle>sd_event_wait</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
122       <citerefentry project='man-pages'><refentrytitle>epoll_ctl</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
123       <citerefentry project='man-pages'><refentrytitle>epoll</refentrytitle><manvolnum>7</manvolnum></citerefentry>
124     </para>
125   </refsect1>
126
127 </refentry>