2 <!DOCTYPE refentry PUBLIC
"-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
6 SPDX-License-Identifier: LGPL-2.1+
9 <refentry id=
"sd_event_exit" xmlns:
xi=
"http://www.w3.org/2001/XInclude">
12 <title>sd_event_exit
</title>
13 <productname>systemd
</productname>
17 <refentrytitle>sd_event_exit
</refentrytitle>
18 <manvolnum>3</manvolnum>
22 <refname>sd_event_exit
</refname>
23 <refname>sd_event_get_exit_code
</refname>
25 <refpurpose>Ask the event loop to exit
</refpurpose>
30 <funcsynopsisinfo>#include
<systemd/sd-event.h
></funcsynopsisinfo>
33 <funcdef>int
<function>sd_event_exit
</function></funcdef>
34 <paramdef>sd_event *
<parameter>event
</parameter></paramdef>
35 <paramdef>int
<parameter>code
</parameter></paramdef>
39 <funcdef>int
<function>sd_event_get_exit_code
</function></funcdef>
40 <paramdef>sd_event *
<parameter>event
</parameter></paramdef>
41 <paramdef>int *
<parameter>code
</parameter></paramdef>
48 <title>Description
</title>
50 <para><function>sd_event_exit()
</function> requests the event loop
51 specified in the
<parameter>event
</parameter> event loop object to
52 exit. The
<parameter>code
</parameter> parameter may be any integer
53 value and is returned as-is by
54 <citerefentry><refentrytitle>sd_event_loop
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
55 after the last event loop iteration. It may also be queried
56 using
<function>sd_event_get_exit_code()
</function>, see
59 <para>When exiting is requested the event loop will stop listening
60 for and dispatching regular event sources. Instead it will proceed
61 with executing only event sources registered with
62 <citerefentry><refentrytitle>sd_event_add_exit
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
63 in the order defined by their priority. After all exit event
64 sources have been dispatched the event loop is terminated.
</para>
66 <para>If
<function>sd_event_exit()
</function> is invoked a second
67 time while the event loop is still processing exit event sources,
68 the exit code stored in the event loop object is updated, but
69 otherwise no further operation is executed.
</para>
71 <para><function>sd_event_get_exit_code()
</function> may be used to
72 query the exit code passed into
73 <function>sd_event_exit()
</function> earlier.
</para>
75 <para>While the full positive and negative integer ranges may be used
76 for the exit code, care should be taken not pick exit codes that
77 conflict with regular exit codes returned by
78 <function>sd_event_loop()
</function>, if these exit codes shall be
79 distinguishable.
</para>
83 <title>Return Value
</title>
85 <para>On success,
<function>sd_event_exit()
</function> and
86 <function>sd_event_get_exit_code()
</function> return
0 or a positive
87 integer. On failure, they return a negative errno-style error
94 <para>Returned errors may indicate the following problems:
</para>
99 <term><constant>-EINVAL
</constant></term>
101 <listitem><para>The event loop object or error code pointer are invalid.
</para></listitem>
106 <term><constant>-ECHILD
</constant></term>
108 <listitem><para>The event loop was created in a different process.
</para></listitem>
112 <term><constant>-ESTALE
</constant></term>
114 <listitem><para>The event loop has exited already and all exit handlers are already processed.
</para></listitem>
118 <term><constant>-ENODATA
</constant></term>
120 <listitem><para>The event loop has not been requested to exit yet.
</para></listitem>
126 <xi:include href=
"libsystemd-pkgconfig.xml" />
129 <title>See Also
</title>
132 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
133 <citerefentry><refentrytitle>sd-event
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
134 <citerefentry><refentrytitle>sd_event_new
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
135 <citerefentry><refentrytitle>sd_event_add_exit
</refentrytitle><manvolnum>3</manvolnum></citerefentry>