]>
Commit | Line | Data |
---|---|---|
514094f9 | 1 | <?xml version='1.0'?> |
3a54a157 ZJS |
2 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" |
3 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> | |
0307f791 | 4 | <!-- SPDX-License-Identifier: LGPL-2.1+ --> |
ba4b3566 | 5 | |
dc83f27a | 6 | <refentry id="sd_event_get_fd" xmlns:xi="http://www.w3.org/2001/XInclude"> |
ba4b3566 ZJS |
7 | |
8 | <refentryinfo> | |
9 | <title>sd_event_get_fd</title> | |
10 | <productname>systemd</productname> | |
ba4b3566 ZJS |
11 | </refentryinfo> |
12 | ||
13 | <refmeta> | |
14 | <refentrytitle>sd_event_get_fd</refentrytitle> | |
15 | <manvolnum>3</manvolnum> | |
16 | </refmeta> | |
17 | ||
18 | <refnamediv> | |
19 | <refname>sd_event_get_fd</refname> | |
20 | ||
21 | <refpurpose>Obtain a file descriptor to poll for event loop events</refpurpose> | |
22 | </refnamediv> | |
23 | ||
24 | <refsynopsisdiv> | |
25 | <funcsynopsis> | |
dc83f27a | 26 | <funcsynopsisinfo>#include <systemd/sd-event.h></funcsynopsisinfo> |
ba4b3566 ZJS |
27 | |
28 | <funcprototype> | |
29 | <funcdef>int <function>sd_event_get_fd</function></funcdef> | |
dc83f27a | 30 | <paramdef>sd_event *<parameter>event</parameter></paramdef> |
ba4b3566 ZJS |
31 | </funcprototype> |
32 | ||
33 | </funcsynopsis> | |
34 | </refsynopsisdiv> | |
35 | ||
36 | <refsect1> | |
37 | <title>Description</title> | |
38 | ||
39 | <para><function>sd_event_get_fd()</function> returns the file | |
dc83f27a | 40 | descriptor that an event loop object returned by the |
ba4b3566 | 41 | <citerefentry><refentrytitle>sd_event_new</refentrytitle><manvolnum>3</manvolnum></citerefentry> |
dc83f27a LP |
42 | function uses to wait for events. This file descriptor may itself |
43 | be polled for | |
44 | <constant>POLLIN</constant>/<constant>EPOLLIN</constant> | |
45 | events. This makes it possible to embed an | |
ba4b3566 | 46 | <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry> |
dc83f27a LP |
47 | event loop into another, possibly foreign, event loop.</para> |
48 | ||
49 | <para>The returned file descriptor refers to an <citerefentry | |
50 | project='man-pages'><refentrytitle>epoll</refentrytitle><manvolnum>7</manvolnum></citerefentry> | |
51 | object. It is recommended not to alter it by invoking | |
52 | <citerefentry | |
53 | project='man-pages'><refentrytitle>epoll_ctl</refentrytitle><manvolnum>2</manvolnum></citerefentry> | |
54 | on it, in order to avoid interference with the event loop's inner | |
55 | logic and assumptions.</para> | |
ba4b3566 ZJS |
56 | </refsect1> |
57 | ||
58 | <refsect1> | |
59 | <title>Return Value</title> | |
60 | ||
61 | <para>On success, <function>sd_event_get_fd()</function> returns a | |
dc83f27a | 62 | non-negative file descriptor. On failure, it returns a negative |
ba4b3566 ZJS |
63 | errno-style error code.</para> |
64 | </refsect1> | |
65 | ||
66 | <refsect1> | |
67 | <title>Errors</title> | |
68 | ||
69 | <para>Returned errors may indicate the following problems:</para> | |
70 | ||
71 | <variablelist> | |
72 | <varlistentry> | |
73 | <term><constant>-EINVAL</constant></term> | |
74 | ||
75 | <listitem><para><parameter>event</parameter> is not a valid | |
76 | pointer to an <structname>sd_event</structname> structure. | |
77 | </para></listitem> | |
78 | </varlistentry> | |
79 | ||
80 | <varlistentry> | |
81 | <term><constant>-ECHILD</constant></term> | |
82 | ||
83 | <listitem><para>The event loop has been created in a different process.</para></listitem> | |
84 | ||
85 | </varlistentry> | |
86 | </variablelist> | |
87 | </refsect1> | |
88 | ||
89 | <refsect1> | |
90 | <title>Examples</title> | |
91 | ||
92 | <example> | |
dc83f27a | 93 | <title>Integration in the GLib event loop</title> |
ba4b3566 ZJS |
94 | |
95 | <programlisting><xi:include href="glib-event-glue.c" parse="text" /></programlisting> | |
96 | </example> | |
97 | </refsect1> | |
98 | ||
dc83f27a | 99 | <xi:include href="libsystemd-pkgconfig.xml" /> |
ba4b3566 ZJS |
100 | |
101 | <refsect1> | |
102 | <title>See Also</title> | |
103 | ||
104 | <para> | |
105 | <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
106 | <citerefentry><refentrytitle>sd_event_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
dc83f27a | 107 | <citerefentry><refentrytitle>sd_event_wait</refentrytitle><manvolnum>3</manvolnum></citerefentry>, |
d3c05587 | 108 | <citerefentry project='man-pages'><refentrytitle>epoll_ctl</refentrytitle><manvolnum>2</manvolnum></citerefentry>, |
dc83f27a | 109 | <citerefentry project='man-pages'><refentrytitle>epoll</refentrytitle><manvolnum>7</manvolnum></citerefentry> |
ba4b3566 ZJS |
110 | </para> |
111 | </refsect1> | |
112 | ||
113 | </refentry> |