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 This file is part of elogind.
8 Copyright 2015 Lennart Poettering
10 elogind 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.
15 elogind 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.
20 You should have received a copy of the GNU Lesser General Public License
21 along with elogind; If not, see <http://www.gnu.org/licenses/>.
24 <refentry id="sd_event_exit" xmlns:xi="http://www.w3.org/2001/XInclude">
27 <title>sd_event_exit</title>
28 <productname>elogind</productname>
32 <contrib>Developer</contrib>
33 <firstname>Lennart</firstname>
34 <surname>Poettering</surname>
35 <email>lennart@poettering.net</email>
41 <refentrytitle>sd_event_exit</refentrytitle>
42 <manvolnum>3</manvolnum>
46 <refname>sd_event_exit</refname>
47 <refname>sd_event_get_exit_code</refname>
49 <refpurpose>Ask the event loop to exit</refpurpose>
54 <funcsynopsisinfo>#include <elogind/sd-event.h></funcsynopsisinfo>
57 <funcdef>int <function>sd_event_exit</function></funcdef>
58 <paramdef>sd_event *<parameter>event</parameter></paramdef>
59 <paramdef>int <parameter>code</parameter></paramdef>
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>
72 <title>Description</title>
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>
79 after the last event loop iteration. It may also be queried
80 using <function>sd_event_get_exit_code()</function>, see
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>
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>
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>
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>
107 <title>Return Value</title>
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
116 <title>Errors</title>
118 <para>Returned errors may indicate the following problems:</para>
123 <term><constant>-EINVAL</constant></term>
125 <listitem><para>The event loop object or error code pointer are invalid.</para></listitem>
130 <term><constant>-ECHILD</constant></term>
132 <listitem><para>The event loop was created in a different process.</para></listitem>
136 <term><constant>-ESTALE</constant></term>
138 <listitem><para>The event loop has exited already and all exit handlers are already processed.</para></listitem>
142 <term><constant>-ENODATA</constant></term>
144 <listitem><para>The event loop has not been requested to exit yet.</para></listitem>
150 <xi:include href="libelogind-pkgconfig.xml" />
153 <title>See Also</title>
156 <citerefentry><refentrytitle>elogind</refentrytitle><manvolnum>8</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>