]>
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 | <!-- | |
6 | This file is part of systemd. | |
7 | ||
8 | Copyright 2015 Lennart Poettering | |
9 | ||
10 | systemd is free software; you can redistribute it and/or modify it | |
11 | under the terms of the GNU Lesser General Public License as published by | |
12 | the Free Software Foundation; either version 2.1 of the License, or | |
13 | (at your option) any later version. | |
14 | ||
15 | systemd is distributed in the hope that it will be useful, but | |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
18 | Lesser General Public License for more details. | |
19 | ||
20 | You should have received a copy of the GNU Lesser General Public License | |
21 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
22 | --> | |
23 | ||
24 | <refentry id="sd_event_exit" xmlns:xi="http://www.w3.org/2001/XInclude"> | |
25 | ||
26 | <refentryinfo> | |
27 | <title>sd_event_exit</title> | |
28 | <productname>systemd</productname> | |
29 | ||
30 | <authorgroup> | |
31 | <author> | |
32 | <contrib>Developer</contrib> | |
33 | <firstname>Lennart</firstname> | |
34 | <surname>Poettering</surname> | |
35 | <email>lennart@poettering.net</email> | |
36 | </author> | |
37 | </authorgroup> | |
38 | </refentryinfo> | |
39 | ||
40 | <refmeta> | |
41 | <refentrytitle>sd_event_exit</refentrytitle> | |
42 | <manvolnum>3</manvolnum> | |
43 | </refmeta> | |
44 | ||
45 | <refnamediv> | |
46 | <refname>sd_event_exit</refname> | |
47 | <refname>sd_event_get_exit_code</refname> | |
48 | ||
49 | <refpurpose>Ask the event loop to exit</refpurpose> | |
50 | </refnamediv> | |
51 | ||
52 | <refsynopsisdiv> | |
53 | <funcsynopsis> | |
54 | <funcsynopsisinfo>#include <systemd/sd-event.h></funcsynopsisinfo> | |
55 | ||
56 | <funcprototype> | |
57 | <funcdef>int <function>sd_event_exit</function></funcdef> | |
58 | <paramdef>sd_event *<parameter>event</parameter></paramdef> | |
59 | <paramdef>int <parameter>code</parameter></paramdef> | |
60 | </funcprototype> | |
61 | ||
62 | <funcprototype> | |
63 | <funcdef>int <function>sd_event_get_exit_code</function></funcdef> | |
64 | <paramdef>sd_event *<parameter>event</parameter></paramdef> | |
65 | <paramdef>int *<parameter>code</parameter></paramdef> | |
66 | </funcprototype> | |
67 | ||
68 | </funcsynopsis> | |
69 | </refsynopsisdiv> | |
70 | ||
71 | <refsect1> | |
72 | <title>Description</title> | |
73 | ||
74 | <para><function>sd_event_exit()</function> requests the event loop | |
75 | specified in the <parameter>event</parameter> event loop object to | |
76 | exit. The <parameter>code</parameter> parameter may be any integer | |
77 | value and is returned as-is by | |
78 | <citerefentry><refentrytitle>sd_event_loop</refentrytitle><manvolnum>3</manvolnum></citerefentry> | |
7f3fdb7f | 79 | after the last event loop iteration. It may also be queried |
dc83f27a LP |
80 | using <function>sd_event_get_exit_code()</function>, see |
81 | below. </para> | |
82 | ||
83 | <para>When exiting is requested the event loop will stop listening | |
84 | for and dispatching regular event sources. Instead it will proceed | |
85 | with executing only event sources registered with | |
86 | <citerefentry><refentrytitle>sd_event_add_exit</refentrytitle><manvolnum>3</manvolnum></citerefentry> | |
87 | in the order defined by their priority. After all exit event | |
88 | sources have been dispatched the event loop is terminated.</para> | |
89 | ||
90 | <para>If <function>sd_event_exit()</function> is invoked a second | |
91 | time while the event loop is still processing exit event sources, | |
92 | the exit code stored in the event loop object is updated, but | |
93 | otherwise no further operation is executed.</para> | |
94 | ||
95 | <para><function>sd_event_get_exit_code()</function> may be used to | |
96 | query the exit code passed into | |
97 | <function>sd_event_exit()</function> earlier.</para> | |
98 | ||
99 | <para>While the full positive and negative integer ranges may be used | |
100 | for the exit code, care should be taken not pick exit codes that | |
101 | conflict with regular exit codes returned by | |
102 | <function>sd_event_loop()</function>, if these exit codes shall be | |
103 | distinguishable.</para> | |
104 | </refsect1> | |
105 | ||
106 | <refsect1> | |
107 | <title>Return Value</title> | |
108 | ||
109 | <para>On success, <function>sd_event_exit()</function> and | |
110 | <function>sd_event_get_exit_code()</function> return 0 or a positive | |
111 | integer. On failure, they return a negative errno-style error | |
112 | code.</para> | |
113 | </refsect1> | |
114 | ||
115 | <refsect1> | |
116 | <title>Errors</title> | |
117 | ||
118 | <para>Returned errors may indicate the following problems:</para> | |
119 | ||
120 | <variablelist> | |
121 | ||
122 | <varlistentry> | |
123 | <term><constant>-EINVAL</constant></term> | |
124 | ||
125 | <listitem><para>The event loop object or error code pointer are invalid.</para></listitem> | |
126 | ||
127 | </varlistentry> | |
128 | ||
129 | <varlistentry> | |
130 | <term><constant>-ECHILD</constant></term> | |
131 | ||
132 | <listitem><para>The event loop was created in a different process.</para></listitem> | |
133 | </varlistentry> | |
134 | ||
135 | <varlistentry> | |
136 | <term><constant>-ESTALE</constant></term> | |
137 | ||
138 | <listitem><para>The event loop has exited already and all exit handlers are already processed.</para></listitem> | |
139 | </varlistentry> | |
140 | ||
141 | <varlistentry> | |
142 | <term><constant>-ENODATA</constant></term> | |
143 | ||
144 | <listitem><para>The event loop has not been requested to exit yet.</para></listitem> | |
145 | </varlistentry> | |
146 | ||
147 | </variablelist> | |
148 | </refsect1> | |
149 | ||
150 | <xi:include href="libsystemd-pkgconfig.xml" /> | |
151 | ||
152 | <refsect1> | |
153 | <title>See Also</title> | |
154 | ||
155 | <para> | |
156 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
157 | <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
158 | <citerefentry><refentrytitle>sd_event_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
159 | <citerefentry><refentrytitle>sd_event_add_exit</refentrytitle><manvolnum>3</manvolnum></citerefentry> | |
160 | </para> | |
161 | </refsect1> | |
162 | ||
163 | </refentry> |