2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
6 <refentry id="sd_event_source_get_pending" xmlns:xi="http://www.w3.org/2001/XInclude">
9 <title>sd_event_source_get_pending</title>
10 <productname>systemd</productname>
14 <refentrytitle>sd_event_source_get_pending</refentrytitle>
15 <manvolnum>3</manvolnum>
19 <refname>sd_event_source_get_pending</refname>
21 <refpurpose>Determine pending state of event sources</refpurpose>
26 <funcsynopsisinfo>#include <systemd/sd-event.h></funcsynopsisinfo>
29 <funcdef>int <function>sd_event_source_get_pending</function></funcdef>
30 <paramdef>sd_event_source *<parameter>source</parameter></paramdef>
37 <title>Description</title>
39 <para><function>sd_event_source_get_pending()</function> may be
40 used to determine whether the event source object specified as
41 <parameter>source</parameter> has seen events but has not been
42 dispatched yet (and thus is marked "pending").</para>
44 <para>Event source objects initially are not marked pending, when
45 they are created with calls such as
46 <citerefentry><refentrytitle>sd_event_add_io</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
47 <citerefentry><refentrytitle>sd_event_add_time</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
48 with the exception of those created with
49 <citerefentry><refentrytitle>sd_event_add_defer</refentrytitle><manvolnum>3</manvolnum></citerefentry>
50 which are immediately marked pending, and
51 <citerefentry><refentrytitle>sd_event_add_exit</refentrytitle><manvolnum>3</manvolnum></citerefentry>
52 for which the "pending" concept is not defined. For details see
53 the respective manual pages.</para>
55 <para>In each event loop iteration one event source of those
56 marked pending is dispatched, in the order defined by the event
57 source priority, as set with
58 <citerefentry><refentrytitle>sd_event_source_set_priority</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para>
60 <para>For I/O event sources, as created with
61 <citerefentry><refentrytitle>sd_event_add_io</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
63 <citerefentry><refentrytitle>sd_event_source_get_io_revents</refentrytitle><manvolnum>3</manvolnum></citerefentry>
64 may be used to query the type of event pending in more
70 <title>Return Value</title>
72 <para>On success, <function>sd_event_source_get_pending()</function> returns an integer greater than zero
73 when the event source is marked pending, and zero when the event source is not marked pending. On
74 failure, it returns a negative errno-style error code.</para>
79 <para>Returned errors may indicate the following problems:</para>
83 <term><constant>-EINVAL</constant></term>
85 <listitem><para><parameter>source</parameter> is not a valid pointer to an
86 <structname>sd_event_source</structname> object.</para></listitem>
90 <term><constant>-EDOM</constant></term>
92 <listitem><para><parameter>source</parameter> refers to an event source object created with
93 <citerefentry><refentrytitle>sd_event_add_exit</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para></listitem>
97 <term><constant>-ENOMEM</constant></term>
99 <listitem><para>Not enough memory.</para></listitem>
103 <term><constant>-ESTALE</constant></term>
105 <listitem><para>The event loop is already terminated.</para></listitem>
110 <term><constant>-ECHILD</constant></term>
112 <listitem><para>The event loop has been created in a different process, library or module instance.</para></listitem>
120 <xi:include href="libsystemd-pkgconfig.xml" />
123 <title>History</title>
124 <para><function>sd_event_source_get_pending()</function> was added in version 229.</para>
128 <title>See Also</title>
130 <para><simplelist type="inline">
131 <member><citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
132 <member><citerefentry><refentrytitle>sd_event_add_io</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
133 <member><citerefentry><refentrytitle>sd_event_add_time</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
134 <member><citerefentry><refentrytitle>sd_event_add_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
135 <member><citerefentry><refentrytitle>sd_event_add_child</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
136 <member><citerefentry><refentrytitle>sd_event_add_inotify</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
137 <member><citerefentry><refentrytitle>sd_event_add_defer</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
138 <member><citerefentry><refentrytitle>sd_event_source_unref</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>