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">
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>elogind</productname>
17 <contrib>Developer</contrib>
18 <firstname>Lennart</firstname>
19 <surname>Poettering</surname>
20 <email>lennart@poettering.net</email>
26 <refentrytitle>sd_event_exit</refentrytitle>
27 <manvolnum>3</manvolnum>
31 <refname>sd_event_exit</refname>
32 <refname>sd_event_get_exit_code</refname>
34 <refpurpose>Ask the event loop to exit</refpurpose>
39 <funcsynopsisinfo>#include <elogind/sd-event.h></funcsynopsisinfo>
42 <funcdef>int <function>sd_event_exit</function></funcdef>
43 <paramdef>sd_event *<parameter>event</parameter></paramdef>
44 <paramdef>int <parameter>code</parameter></paramdef>
48 <funcdef>int <function>sd_event_get_exit_code</function></funcdef>
49 <paramdef>sd_event *<parameter>event</parameter></paramdef>
50 <paramdef>int *<parameter>code</parameter></paramdef>
57 <title>Description</title>
59 <para><function>sd_event_exit()</function> requests the event loop
60 specified in the <parameter>event</parameter> event loop object to
61 exit. The <parameter>code</parameter> parameter may be any integer
62 value and is returned as-is by
63 <citerefentry><refentrytitle>sd_event_loop</refentrytitle><manvolnum>3</manvolnum></citerefentry>
64 after the last event loop iteration. It may also be queried
65 using <function>sd_event_get_exit_code()</function>, see
68 <para>When exiting is requested the event loop will stop listening
69 for and dispatching regular event sources. Instead it will proceed
70 with executing only event sources registered with
71 <citerefentry><refentrytitle>sd_event_add_exit</refentrytitle><manvolnum>3</manvolnum></citerefentry>
72 in the order defined by their priority. After all exit event
73 sources have been dispatched the event loop is terminated.</para>
75 <para>If <function>sd_event_exit()</function> is invoked a second
76 time while the event loop is still processing exit event sources,
77 the exit code stored in the event loop object is updated, but
78 otherwise no further operation is executed.</para>
80 <para><function>sd_event_get_exit_code()</function> may be used to
81 query the exit code passed into
82 <function>sd_event_exit()</function> earlier.</para>
84 <para>While the full positive and negative integer ranges may be used
85 for the exit code, care should be taken not pick exit codes that
86 conflict with regular exit codes returned by
87 <function>sd_event_loop()</function>, if these exit codes shall be
88 distinguishable.</para>
92 <title>Return Value</title>
94 <para>On success, <function>sd_event_exit()</function> and
95 <function>sd_event_get_exit_code()</function> return 0 or a positive
96 integer. On failure, they return a negative errno-style error
101 <title>Errors</title>
103 <para>Returned errors may indicate the following problems:</para>
108 <term><constant>-EINVAL</constant></term>
110 <listitem><para>The event loop object or error code pointer are invalid.</para></listitem>
115 <term><constant>-ECHILD</constant></term>
117 <listitem><para>The event loop was created in a different process.</para></listitem>
121 <term><constant>-ESTALE</constant></term>
123 <listitem><para>The event loop has exited already and all exit handlers are already processed.</para></listitem>
127 <term><constant>-ENODATA</constant></term>
129 <listitem><para>The event loop has not been requested to exit yet.</para></listitem>
135 <xi:include href="libelogind-pkgconfig.xml" />
138 <title>See Also</title>
141 <!-- 0 /// elogind is in section 8
142 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
144 <citerefentry><refentrytitle>elogind</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
146 <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
147 <citerefentry><refentrytitle>sd_event_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
148 <citerefentry><refentrytitle>sd_event_add_exit</refentrytitle><manvolnum>3</manvolnum></citerefentry>