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