]>
Commit | Line | Data |
---|---|---|
514094f9 | 1 | <?xml version='1.0'?> |
dc83f27a LP |
2 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" |
3 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> | |
4 | ||
5 | <!-- | |
572eb058 | 6 | SPDX-License-Identifier: LGPL-2.1+ |
dc83f27a LP |
7 | --> |
8 | ||
9 | <refentry id="sd_event_exit" xmlns:xi="http://www.w3.org/2001/XInclude"> | |
10 | ||
11 | <refentryinfo> | |
12 | <title>sd_event_exit</title> | |
13 | <productname>systemd</productname> | |
dc83f27a LP |
14 | </refentryinfo> |
15 | ||
16 | <refmeta> | |
17 | <refentrytitle>sd_event_exit</refentrytitle> | |
18 | <manvolnum>3</manvolnum> | |
19 | </refmeta> | |
20 | ||
21 | <refnamediv> | |
22 | <refname>sd_event_exit</refname> | |
23 | <refname>sd_event_get_exit_code</refname> | |
24 | ||
25 | <refpurpose>Ask the event loop to exit</refpurpose> | |
26 | </refnamediv> | |
27 | ||
28 | <refsynopsisdiv> | |
29 | <funcsynopsis> | |
30 | <funcsynopsisinfo>#include <systemd/sd-event.h></funcsynopsisinfo> | |
31 | ||
32 | <funcprototype> | |
33 | <funcdef>int <function>sd_event_exit</function></funcdef> | |
34 | <paramdef>sd_event *<parameter>event</parameter></paramdef> | |
35 | <paramdef>int <parameter>code</parameter></paramdef> | |
36 | </funcprototype> | |
37 | ||
38 | <funcprototype> | |
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> | |
42 | </funcprototype> | |
43 | ||
44 | </funcsynopsis> | |
45 | </refsynopsisdiv> | |
46 | ||
47 | <refsect1> | |
48 | <title>Description</title> | |
49 | ||
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> | |
7f3fdb7f | 55 | after the last event loop iteration. It may also be queried |
dc83f27a LP |
56 | using <function>sd_event_get_exit_code()</function>, see |
57 | below. </para> | |
58 | ||
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> | |
65 | ||
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> | |
70 | ||
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> | |
74 | ||
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> | |
80 | </refsect1> | |
81 | ||
82 | <refsect1> | |
83 | <title>Return Value</title> | |
84 | ||
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 | |
88 | code.</para> | |
89 | </refsect1> | |
90 | ||
91 | <refsect1> | |
92 | <title>Errors</title> | |
93 | ||
94 | <para>Returned errors may indicate the following problems:</para> | |
95 | ||
96 | <variablelist> | |
97 | ||
98 | <varlistentry> | |
99 | <term><constant>-EINVAL</constant></term> | |
100 | ||
101 | <listitem><para>The event loop object or error code pointer are invalid.</para></listitem> | |
102 | ||
103 | </varlistentry> | |
104 | ||
105 | <varlistentry> | |
106 | <term><constant>-ECHILD</constant></term> | |
107 | ||
108 | <listitem><para>The event loop was created in a different process.</para></listitem> | |
109 | </varlistentry> | |
110 | ||
111 | <varlistentry> | |
112 | <term><constant>-ESTALE</constant></term> | |
113 | ||
114 | <listitem><para>The event loop has exited already and all exit handlers are already processed.</para></listitem> | |
115 | </varlistentry> | |
116 | ||
117 | <varlistentry> | |
118 | <term><constant>-ENODATA</constant></term> | |
119 | ||
120 | <listitem><para>The event loop has not been requested to exit yet.</para></listitem> | |
121 | </varlistentry> | |
122 | ||
123 | </variablelist> | |
124 | </refsect1> | |
125 | ||
126 | <xi:include href="libsystemd-pkgconfig.xml" /> | |
127 | ||
128 | <refsect1> | |
129 | <title>See Also</title> | |
130 | ||
131 | <para> | |
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> | |
136 | </para> | |
137 | </refsect1> | |
138 | ||
139 | </refentry> |