]>
Commit | Line | Data |
---|---|---|
dc83f27a LP |
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"> | |
4 | ||
5 | <!-- | |
572eb058 ZJS |
6 | SPDX-License-Identifier: LGPL-2.1+ |
7 | ||
dc83f27a LP |
8 | This file is part of systemd. |
9 | ||
10 | Copyright 2015 Lennart Poettering | |
11 | ||
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. | |
16 | ||
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. | |
21 | ||
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/>. | |
24 | --> | |
25 | ||
26 | <refentry id="sd_event_exit" xmlns:xi="http://www.w3.org/2001/XInclude"> | |
27 | ||
28 | <refentryinfo> | |
29 | <title>sd_event_exit</title> | |
30 | <productname>systemd</productname> | |
31 | ||
32 | <authorgroup> | |
33 | <author> | |
34 | <contrib>Developer</contrib> | |
35 | <firstname>Lennart</firstname> | |
36 | <surname>Poettering</surname> | |
37 | <email>lennart@poettering.net</email> | |
38 | </author> | |
39 | </authorgroup> | |
40 | </refentryinfo> | |
41 | ||
42 | <refmeta> | |
43 | <refentrytitle>sd_event_exit</refentrytitle> | |
44 | <manvolnum>3</manvolnum> | |
45 | </refmeta> | |
46 | ||
47 | <refnamediv> | |
48 | <refname>sd_event_exit</refname> | |
49 | <refname>sd_event_get_exit_code</refname> | |
50 | ||
51 | <refpurpose>Ask the event loop to exit</refpurpose> | |
52 | </refnamediv> | |
53 | ||
54 | <refsynopsisdiv> | |
55 | <funcsynopsis> | |
56 | <funcsynopsisinfo>#include <systemd/sd-event.h></funcsynopsisinfo> | |
57 | ||
58 | <funcprototype> | |
59 | <funcdef>int <function>sd_event_exit</function></funcdef> | |
60 | <paramdef>sd_event *<parameter>event</parameter></paramdef> | |
61 | <paramdef>int <parameter>code</parameter></paramdef> | |
62 | </funcprototype> | |
63 | ||
64 | <funcprototype> | |
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> | |
68 | </funcprototype> | |
69 | ||
70 | </funcsynopsis> | |
71 | </refsynopsisdiv> | |
72 | ||
73 | <refsect1> | |
74 | <title>Description</title> | |
75 | ||
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> | |
7f3fdb7f | 81 | after the last event loop iteration. It may also be queried |
dc83f27a LP |
82 | using <function>sd_event_get_exit_code()</function>, see |
83 | below. </para> | |
84 | ||
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> | |
91 | ||
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> | |
96 | ||
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> | |
100 | ||
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> | |
106 | </refsect1> | |
107 | ||
108 | <refsect1> | |
109 | <title>Return Value</title> | |
110 | ||
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 | |
114 | code.</para> | |
115 | </refsect1> | |
116 | ||
117 | <refsect1> | |
118 | <title>Errors</title> | |
119 | ||
120 | <para>Returned errors may indicate the following problems:</para> | |
121 | ||
122 | <variablelist> | |
123 | ||
124 | <varlistentry> | |
125 | <term><constant>-EINVAL</constant></term> | |
126 | ||
127 | <listitem><para>The event loop object or error code pointer are invalid.</para></listitem> | |
128 | ||
129 | </varlistentry> | |
130 | ||
131 | <varlistentry> | |
132 | <term><constant>-ECHILD</constant></term> | |
133 | ||
134 | <listitem><para>The event loop was created in a different process.</para></listitem> | |
135 | </varlistentry> | |
136 | ||
137 | <varlistentry> | |
138 | <term><constant>-ESTALE</constant></term> | |
139 | ||
140 | <listitem><para>The event loop has exited already and all exit handlers are already processed.</para></listitem> | |
141 | </varlistentry> | |
142 | ||
143 | <varlistentry> | |
144 | <term><constant>-ENODATA</constant></term> | |
145 | ||
146 | <listitem><para>The event loop has not been requested to exit yet.</para></listitem> | |
147 | </varlistentry> | |
148 | ||
149 | </variablelist> | |
150 | </refsect1> | |
151 | ||
152 | <xi:include href="libsystemd-pkgconfig.xml" /> | |
153 | ||
154 | <refsect1> | |
155 | <title>See Also</title> | |
156 | ||
157 | <para> | |
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> | |
162 | </para> | |
163 | </refsect1> | |
164 | ||
165 | </refentry> |