]>
Commit | Line | Data |
---|---|---|
514094f9 | 1 | <?xml version='1.0'?> |
3a54a157 ZJS |
2 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" |
3 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> | |
0307f791 | 4 | <!-- SPDX-License-Identifier: LGPL-2.1+ --> |
dc83f27a LP |
5 | |
6 | <refentry id="sd_event_exit" xmlns:xi="http://www.w3.org/2001/XInclude"> | |
7 | ||
8 | <refentryinfo> | |
9 | <title>sd_event_exit</title> | |
10 | <productname>systemd</productname> | |
dc83f27a LP |
11 | </refentryinfo> |
12 | ||
13 | <refmeta> | |
14 | <refentrytitle>sd_event_exit</refentrytitle> | |
15 | <manvolnum>3</manvolnum> | |
16 | </refmeta> | |
17 | ||
18 | <refnamediv> | |
19 | <refname>sd_event_exit</refname> | |
20 | <refname>sd_event_get_exit_code</refname> | |
21 | ||
22 | <refpurpose>Ask the event loop to exit</refpurpose> | |
23 | </refnamediv> | |
24 | ||
25 | <refsynopsisdiv> | |
26 | <funcsynopsis> | |
27 | <funcsynopsisinfo>#include <systemd/sd-event.h></funcsynopsisinfo> | |
28 | ||
29 | <funcprototype> | |
30 | <funcdef>int <function>sd_event_exit</function></funcdef> | |
31 | <paramdef>sd_event *<parameter>event</parameter></paramdef> | |
32 | <paramdef>int <parameter>code</parameter></paramdef> | |
33 | </funcprototype> | |
34 | ||
35 | <funcprototype> | |
36 | <funcdef>int <function>sd_event_get_exit_code</function></funcdef> | |
37 | <paramdef>sd_event *<parameter>event</parameter></paramdef> | |
38 | <paramdef>int *<parameter>code</parameter></paramdef> | |
39 | </funcprototype> | |
40 | ||
41 | </funcsynopsis> | |
42 | </refsynopsisdiv> | |
43 | ||
44 | <refsect1> | |
45 | <title>Description</title> | |
46 | ||
47 | <para><function>sd_event_exit()</function> requests the event loop | |
48 | specified in the <parameter>event</parameter> event loop object to | |
49 | exit. The <parameter>code</parameter> parameter may be any integer | |
50 | value and is returned as-is by | |
51 | <citerefentry><refentrytitle>sd_event_loop</refentrytitle><manvolnum>3</manvolnum></citerefentry> | |
7f3fdb7f | 52 | after the last event loop iteration. It may also be queried |
dc83f27a LP |
53 | using <function>sd_event_get_exit_code()</function>, see |
54 | below. </para> | |
55 | ||
56 | <para>When exiting is requested the event loop will stop listening | |
57 | for and dispatching regular event sources. Instead it will proceed | |
58 | with executing only event sources registered with | |
59 | <citerefentry><refentrytitle>sd_event_add_exit</refentrytitle><manvolnum>3</manvolnum></citerefentry> | |
60 | in the order defined by their priority. After all exit event | |
61 | sources have been dispatched the event loop is terminated.</para> | |
62 | ||
63 | <para>If <function>sd_event_exit()</function> is invoked a second | |
64 | time while the event loop is still processing exit event sources, | |
65 | the exit code stored in the event loop object is updated, but | |
66 | otherwise no further operation is executed.</para> | |
67 | ||
68 | <para><function>sd_event_get_exit_code()</function> may be used to | |
69 | query the exit code passed into | |
70 | <function>sd_event_exit()</function> earlier.</para> | |
71 | ||
72 | <para>While the full positive and negative integer ranges may be used | |
73 | for the exit code, care should be taken not pick exit codes that | |
74 | conflict with regular exit codes returned by | |
75 | <function>sd_event_loop()</function>, if these exit codes shall be | |
76 | distinguishable.</para> | |
77 | </refsect1> | |
78 | ||
79 | <refsect1> | |
80 | <title>Return Value</title> | |
81 | ||
b1de39de ZJS |
82 | <para>On success, <function>sd_event_exit()</function> and <function>sd_event_get_exit_code()</function> |
83 | return 0 or a positive integer. On failure, they return a negative errno-style error code.</para> | |
dc83f27a | 84 | |
b1de39de ZJS |
85 | <refsect2> |
86 | <title>Errors</title> | |
dc83f27a | 87 | |
b1de39de | 88 | <para>Returned errors may indicate the following problems:</para> |
dc83f27a | 89 | |
b1de39de | 90 | <variablelist> |
dc83f27a | 91 | |
b1de39de ZJS |
92 | <varlistentry> |
93 | <term><constant>-EINVAL</constant></term> | |
dc83f27a | 94 | |
b1de39de | 95 | <listitem><para>The event loop object or error code pointer are invalid.</para></listitem> |
dc83f27a | 96 | |
b1de39de | 97 | </varlistentry> |
dc83f27a | 98 | |
b1de39de ZJS |
99 | <varlistentry> |
100 | <term><constant>-ECHILD</constant></term> | |
dc83f27a | 101 | |
b1de39de ZJS |
102 | <listitem><para>The event loop was created in a different process.</para></listitem> |
103 | </varlistentry> | |
dc83f27a | 104 | |
b1de39de ZJS |
105 | <varlistentry> |
106 | <term><constant>-ESTALE</constant></term> | |
dc83f27a | 107 | |
b1de39de ZJS |
108 | <listitem><para>The event loop has exited already and all exit handlers are already processed. |
109 | </para></listitem> | |
110 | </varlistentry> | |
dc83f27a | 111 | |
b1de39de ZJS |
112 | <varlistentry> |
113 | <term><constant>-ENODATA</constant></term> | |
dc83f27a | 114 | |
b1de39de ZJS |
115 | <listitem><para>The event loop has not been requested to exit yet.</para></listitem> |
116 | </varlistentry> | |
dc83f27a | 117 | |
b1de39de ZJS |
118 | </variablelist> |
119 | </refsect2> | |
dc83f27a LP |
120 | </refsect1> |
121 | ||
122 | <xi:include href="libsystemd-pkgconfig.xml" /> | |
123 | ||
124 | <refsect1> | |
125 | <title>See Also</title> | |
126 | ||
127 | <para> | |
128 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
129 | <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
130 | <citerefentry><refentrytitle>sd_event_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
131 | <citerefentry><refentrytitle>sd_event_add_exit</refentrytitle><manvolnum>3</manvolnum></citerefentry> | |
132 | </para> | |
133 | </refsect1> | |
134 | ||
135 | </refentry> |