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
13 <refentry id=
"sd_event_exit" xmlns:
xi=
"http://www.w3.org/2001/XInclude">
16 <title>sd_event_exit
</title>
17 <productname>systemd
</productname>
21 <contrib>Developer
</contrib>
22 <firstname>Lennart
</firstname>
23 <surname>Poettering
</surname>
24 <email>lennart@poettering.net
</email>
30 <refentrytitle>sd_event_exit
</refentrytitle>
31 <manvolnum>3</manvolnum>
35 <refname>sd_event_exit
</refname>
36 <refname>sd_event_get_exit_code
</refname>
38 <refpurpose>Ask the event loop to exit
</refpurpose>
43 <funcsynopsisinfo>#include
<systemd/sd-event.h
></funcsynopsisinfo>
46 <funcdef>int
<function>sd_event_exit
</function></funcdef>
47 <paramdef>sd_event *
<parameter>event
</parameter></paramdef>
48 <paramdef>int
<parameter>code
</parameter></paramdef>
52 <funcdef>int
<function>sd_event_get_exit_code
</function></funcdef>
53 <paramdef>sd_event *
<parameter>event
</parameter></paramdef>
54 <paramdef>int *
<parameter>code
</parameter></paramdef>
61 <title>Description
</title>
63 <para><function>sd_event_exit()
</function> requests the event loop
64 specified in the
<parameter>event
</parameter> event loop object to
65 exit. The
<parameter>code
</parameter> parameter may be any integer
66 value and is returned as-is by
67 <citerefentry><refentrytitle>sd_event_loop
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
68 after the last event loop iteration. It may also be queried
69 using
<function>sd_event_get_exit_code()
</function>, see
72 <para>When exiting is requested the event loop will stop listening
73 for and dispatching regular event sources. Instead it will proceed
74 with executing only event sources registered with
75 <citerefentry><refentrytitle>sd_event_add_exit
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
76 in the order defined by their priority. After all exit event
77 sources have been dispatched the event loop is terminated.
</para>
79 <para>If
<function>sd_event_exit()
</function> is invoked a second
80 time while the event loop is still processing exit event sources,
81 the exit code stored in the event loop object is updated, but
82 otherwise no further operation is executed.
</para>
84 <para><function>sd_event_get_exit_code()
</function> may be used to
85 query the exit code passed into
86 <function>sd_event_exit()
</function> earlier.
</para>
88 <para>While the full positive and negative integer ranges may be used
89 for the exit code, care should be taken not pick exit codes that
90 conflict with regular exit codes returned by
91 <function>sd_event_loop()
</function>, if these exit codes shall be
92 distinguishable.
</para>
96 <title>Return Value
</title>
98 <para>On success,
<function>sd_event_exit()
</function> and
99 <function>sd_event_get_exit_code()
</function> return
0 or a positive
100 integer. On failure, they return a negative errno-style error
105 <title>Errors
</title>
107 <para>Returned errors may indicate the following problems:
</para>
112 <term><constant>-EINVAL
</constant></term>
114 <listitem><para>The event loop object or error code pointer are invalid.
</para></listitem>
119 <term><constant>-ECHILD
</constant></term>
121 <listitem><para>The event loop was created in a different process.
</para></listitem>
125 <term><constant>-ESTALE
</constant></term>
127 <listitem><para>The event loop has exited already and all exit handlers are already processed.
</para></listitem>
131 <term><constant>-ENODATA
</constant></term>
133 <listitem><para>The event loop has not been requested to exit yet.
</para></listitem>
139 <xi:include href=
"libsystemd-pkgconfig.xml" />
142 <title>See Also
</title>
145 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</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>