systemd/man/sd_event_add_exit.html
2015-02-17 11:22:16 +01:00

58 lines
8.2 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>sd_event_add_defer</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><style>
a.headerlink {
color: #c60f0f;
font-size: 0.8em;
padding: 0 4px 0 4px;
text-decoration: none;
visibility: hidden;
}
a.headerlink:hover {
background-color: #c60f0f;
color: white;
}
h1:hover > a.headerlink, h2:hover > a.headerlink, h3:hover > a.headerlink, dt:hover > a.headerlink {
visibility: visible;
}
</style><a href="index.html">Index </a>·
<a href="systemd.directives.html">Directives </a>·
<a href="../python-systemd/index.html">Python </a>·
<a href="../libudev/index.html">libudev </a>·
<a href="../libudev/index.html">gudev </a><span style="float:right">systemd 219</span><hr><div class="refentry"><a name="sd_event_add_defer"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>sd_event_add_defer, sd_event_add_post, sd_event_add_exit — Add static event sources to an event loop</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include &lt;systemd/sd-bus.h&gt;</pre><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_event_add_defer</b>(</code></td><td>sd_event *<var class="pdparam">event</var>, </td></tr><tr><td> </td><td>sd_event_source **<var class="pdparam">source</var>, </td></tr><tr><td> </td><td>sd_event_handler_t <var class="pdparam">handler</var>, </td></tr><tr><td> </td><td>void *<var class="pdparam">userdata</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_event_add_post</b>(</code></td><td>sd_event *<var class="pdparam">event</var>, </td></tr><tr><td> </td><td>sd_event_source **<var class="pdparam">source</var>, </td></tr><tr><td> </td><td>sd_event_handler_t <var class="pdparam">handler</var>, </td></tr><tr><td> </td><td>void *<var class="pdparam">userdata</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_event_add_exit</b>(</code></td><td>sd_event *<var class="pdparam">event</var>, </td></tr><tr><td> </td><td>sd_event_source **<var class="pdparam">source</var>, </td></tr><tr><td> </td><td>sd_event_handler_t <var class="pdparam">handler</var>, </td></tr><tr><td> </td><td>void *<var class="pdparam">userdata</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">typedef int (*<b class="fsfunc">sd_event_handler_t</b>)(</code></td><td>sd_event_source *<var class="pdparam">s</var>, </td></tr><tr><td> </td><td>void *<var class="pdparam">userdata</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1"><a name="idm140723014876032"></a><h2 id="Description">Description<a class="headerlink" title="Permalink to this headline" href="#Description"></a></h2><p>Those three functions add new event sources to an event loop
object. The event loop is specified in
<em class="parameter"><code>event</code></em>, the event source is returned in the
<em class="parameter"><code>source</code></em> parameter. The event sources are
enabled statically and will "fire" when the event loop is run and
the conditions described below are met. The handler function will
be passed the <em class="parameter"><code>userdata</code></em> pointer, which may
be chosen freely by the caller.</p><p><code class="function">sd_event_add_defer()</code> adds a new event
source that will "fire" the next time the event loop is run. By
default, the handler will be called once
(<code class="constant">SD_EVENT_ONESHOT</code>).</p><p><code class="function">sd_event_add_post()</code> adds a new event
source that will "fire" if any event handlers are invoked whenever
the event loop is run. By default, the source is enabled
permanently (<code class="constant">SD_EVENT_ON</code>).</p><p><code class="function">sd_event_add_exit()</code> adds a new event
source that will "fire" when the event loop is terminated
with <code class="function">sd_event_exit()</code>.</p><p>The
<a href="sd_event_source_set_enabled.html"><span class="citerefentry"><span class="refentrytitle">sd_event_source_set_enabled</span>(3)</span></a>
function may be used to enable the event source permanently
(<code class="constant">SD_EVENT_ON</code>) or to make it fire just once
(<code class="constant">SD_EVENT_ONESHOT</code>). If the handler function
returns a negative error code, it will be disabled after the
invocation, even if <code class="constant">SD_EVENT_ON</code> mode is
set.</p></div><div class="refsect1"><a name="idm140723018767568"></a><h2 id="Return Value">Return Value<a class="headerlink" title="Permalink to this headline" href="#Return%20Value"></a></h2><p>On success, this functions return 0 or a positive
integer. On failure, they return a negative errno-style error
code.</p></div><div class="refsect1"><a name="idm140723018766240"></a><h2 id="Errors">Errors<a class="headerlink" title="Permalink to this headline" href="#Errors"></a></h2><p>Returned errors may indicate the following problems:</p><div class="variablelist"><dl class="variablelist"><dt id="-ENOMEM"><span class="term"><code class="constant">-ENOMEM</code></span><a class="headerlink" title="Permalink to this term" href="#-ENOMEM"></a></dt><dd><p>Not enough memory to allocate an object.</p></dd><dt id="-EINVAL"><span class="term"><code class="constant">-EINVAL</code></span><a class="headerlink" title="Permalink to this term" href="#-EINVAL"></a></dt><dd><p>An invalid argument has been passed.</p></dd><dt id="-ESTALE"><span class="term"><code class="constant">-ESTALE</code></span><a class="headerlink" title="Permalink to this term" href="#-ESTALE"></a></dt><dd><p>The event loop is already terminated.</p></dd><dt id="-ECHILD"><span class="term"><code class="constant">-ECHILD</code></span><a class="headerlink" title="Permalink to this term" href="#-ECHILD"></a></dt><dd><p>The event loop has been created in a different process.</p></dd></dl></div></div><div class="refsect1"><a name="idm140723018758816"></a><h2 id="Notes">Notes<a class="headerlink" title="Permalink to this headline" href="#Notes"></a></h2><p>Functions described here are available as a shared library,
which can be compiled and linked to with the
<code class="constant">libsystemd</code> <a href="http://linux.die.net/man/1/pkg-config"><span class="citerefentry"><span class="refentrytitle">pkg-config</span>(1)</span></a>
file.</p></div><div class="refsect1"><a name="idm140723018748608"></a><h2 id="See Also">See Also<a class="headerlink" title="Permalink to this headline" href="#See%20Also"></a></h2><p>
<a href="systemd.html"><span class="citerefentry"><span class="refentrytitle">systemd</span>(1)</span></a>,
<a href="sd-event.html"><span class="citerefentry"><span class="refentrytitle">sd-event</span>(3)</span></a>,
<a href="sd_event_new.html"><span class="citerefentry"><span class="refentrytitle">sd_event_new</span>(3)</span></a>,
<a href="sd_event_add_time.html"><span class="citerefentry"><span class="refentrytitle">sd_event_add_time</span>(3)</span></a>,
<a href="sd_event_add_signal.html"><span class="citerefentry"><span class="refentrytitle">sd_event_add_signal</span>(3)</span></a>,
<a href="sd_event_add_child.html"><span class="citerefentry"><span class="refentrytitle">sd_event_add_child</span>(3)</span></a>,
<a href="sd_event_source_set_enabled.html"><span class="citerefentry"><span class="refentrytitle">sd_event_source_set_enabled</span>(3)</span></a>
</p></div></div></body></html>