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+
8 This file is part of systemd.
10 Copyright 2015 Lennart Poettering
12 systemd is free software; you can redistribute it and/or modify it
13 under the terms of the GNU Lesser General Public License as published by
14 the Free Software Foundation; either version 2.1 of the License, or
15 (at your option) any later version.
17 systemd is distributed in the hope that it will be useful, but
18 WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 Lesser General Public License for more details.
22 You should have received a copy of the GNU Lesser General Public License
23 along with systemd; If not, see <http://www.gnu.org/licenses/>.
26 <refentry id=
"sd_event_exit" xmlns:
xi=
"http://www.w3.org/2001/XInclude">
29 <title>sd_event_exit
</title>
30 <productname>systemd
</productname>
34 <contrib>Developer
</contrib>
35 <firstname>Lennart
</firstname>
36 <surname>Poettering
</surname>
37 <email>lennart@poettering.net
</email>
43 <refentrytitle>sd_event_exit
</refentrytitle>
44 <manvolnum>3</manvolnum>
48 <refname>sd_event_exit
</refname>
49 <refname>sd_event_get_exit_code
</refname>
51 <refpurpose>Ask the event loop to exit
</refpurpose>
56 <funcsynopsisinfo>#include
<systemd/sd-event.h
></funcsynopsisinfo>
59 <funcdef>int
<function>sd_event_exit
</function></funcdef>
60 <paramdef>sd_event *
<parameter>event
</parameter></paramdef>
61 <paramdef>int
<parameter>code
</parameter></paramdef>
65 <funcdef>int
<function>sd_event_get_exit_code
</function></funcdef>
66 <paramdef>sd_event *
<parameter>event
</parameter></paramdef>
67 <paramdef>int *
<parameter>code
</parameter></paramdef>
74 <title>Description
</title>
76 <para><function>sd_event_exit()
</function> requests the event loop
77 specified in the
<parameter>event
</parameter> event loop object to
78 exit. The
<parameter>code
</parameter> parameter may be any integer
79 value and is returned as-is by
80 <citerefentry><refentrytitle>sd_event_loop
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
81 after the last event loop iteration. It may also be queried
82 using
<function>sd_event_get_exit_code()
</function>, see
85 <para>When exiting is requested the event loop will stop listening
86 for and dispatching regular event sources. Instead it will proceed
87 with executing only event sources registered with
88 <citerefentry><refentrytitle>sd_event_add_exit
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
89 in the order defined by their priority. After all exit event
90 sources have been dispatched the event loop is terminated.
</para>
92 <para>If
<function>sd_event_exit()
</function> is invoked a second
93 time while the event loop is still processing exit event sources,
94 the exit code stored in the event loop object is updated, but
95 otherwise no further operation is executed.
</para>
97 <para><function>sd_event_get_exit_code()
</function> may be used to
98 query the exit code passed into
99 <function>sd_event_exit()
</function> earlier.
</para>
101 <para>While the full positive and negative integer ranges may be used
102 for the exit code, care should be taken not pick exit codes that
103 conflict with regular exit codes returned by
104 <function>sd_event_loop()
</function>, if these exit codes shall be
105 distinguishable.
</para>
109 <title>Return Value
</title>
111 <para>On success,
<function>sd_event_exit()
</function> and
112 <function>sd_event_get_exit_code()
</function> return
0 or a positive
113 integer. On failure, they return a negative errno-style error
118 <title>Errors
</title>
120 <para>Returned errors may indicate the following problems:
</para>
125 <term><constant>-EINVAL
</constant></term>
127 <listitem><para>The event loop object or error code pointer are invalid.
</para></listitem>
132 <term><constant>-ECHILD
</constant></term>
134 <listitem><para>The event loop was created in a different process.
</para></listitem>
138 <term><constant>-ESTALE
</constant></term>
140 <listitem><para>The event loop has exited already and all exit handlers are already processed.
</para></listitem>
144 <term><constant>-ENODATA
</constant></term>
146 <listitem><para>The event loop has not been requested to exit yet.
</para></listitem>
152 <xi:include href=
"libsystemd-pkgconfig.xml" />
155 <title>See Also
</title>
158 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
159 <citerefentry><refentrytitle>sd-event
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
160 <citerefentry><refentrytitle>sd_event_new
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
161 <citerefentry><refentrytitle>sd_event_add_exit
</refentrytitle><manvolnum>3</manvolnum></citerefentry>