]> git.proxmox.com Git - systemd.git/blob - man/sd_event_loop.html
Imported Upstream version 220
[systemd.git] / man / sd_event_loop.html
1 <html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>sd_event_run</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><style>
2 a.headerlink {
3 color: #c60f0f;
4 font-size: 0.8em;
5 padding: 0 4px 0 4px;
6 text-decoration: none;
7 visibility: hidden;
8 }
9
10 a.headerlink:hover {
11 background-color: #c60f0f;
12 color: white;
13 }
14
15 h1:hover > a.headerlink, h2:hover > a.headerlink, h3:hover > a.headerlink, dt:hover > a.headerlink {
16 visibility: visible;
17 }
18 </style><a href="index.html">Index </a>·
19 <a href="systemd.directives.html">Directives </a>·
20 <a href="../python-systemd/index.html">Python </a>·
21 <a href="../libudev/index.html">libudev </a>·
22 <a href="../libudev/index.html">gudev </a><span style="float:right">systemd 220</span><hr><div class="refentry"><a name="sd_event_run"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>sd_event_run, sd_event_loop — Run libsystemd event loop</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include &lt;systemd/sd-event.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_run</b>(</code></td><td>sd_event *<var class="pdparam">event</var>, </td></tr><tr><td> </td><td>uint64_t <var class="pdparam">timeout</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_loop</b>(</code></td><td>sd_event *<var class="pdparam">event</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1"><a name="idm140674379557392"></a><h2 id="Description">Description<a class="headerlink" title="Permalink to this headline" href="#Description"></a></h2><p><code class="function">sd_event_run()</code> can be used to run one
23 iteration of the event loop of libsystemd. This function waits
24 until an event to process is available and dispatches a handler
25 for it. Parameter <em class="parameter"><code>timeout</code></em> specifices the
26 maximum time (in microseconds) to wait. <code class="constant">(uint64_t)
27 -1</code> may be used to specify an infinite timeout.</p><p><code class="function">sd_event_loop</code> runs
28 <code class="function">sd_event_wait</code> in a loop with a timeout of
29 infinity. This makes it suitable for the main event loop of a
30 program.</p><p>The event loop object <em class="parameter"><code>event</code></em> is
31 created with
32 <code class="function">sd_event_new</code>.
33 Events to wait for and their handlers can be registered with
34 <code class="function">sd_event_add_time</code>,
35 <code class="function">sd_event_add_child</code>,
36 <code class="function">sd_event_add_signal</code>,
37 <code class="function">sd_event_add_defer</code>,
38 <code class="function">sd_event_add_exit</code>,
39 and
40 <code class="function">sd_event_add_post</code>.
41 </p><p>For more fine-grained control,
42 <code class="function">sd_event_prepare</code>,
43 <code class="function">sd_event_wait</code>, and
44 <code class="function">sd_event_dispatch</code> may be used. Along with
45 <code class="function">sd_event_get_fd</code>, those functions make it
46 possible to integrate the libsystemd loop inside of another event
47 loop.</p></div><div class="refsect1"><a name="idm140674379544528"></a><h2 id="Return Value">Return Value<a class="headerlink" title="Permalink to this headline" href="#Return%20Value"></a></h2><p>On success, these functions return 0 or a positive integer.
48 On failure, they return a negative errno-style error code.
49 <code class="function">sd_event_run</code> returns 0 if the event loop is
50 finished, and a positive value if it can be continued.</p></div><div class="refsect1"><a name="idm140674379542496"></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="-EINVAL"><span class="term"><code class="constant">-EINVAL</code></span><a class="headerlink" title="Permalink to this term" href="#-EINVAL"></a></dt><dd><p>Parameter <em class="parameter"><code>event</code></em> is
51 <code class="constant">NULL</code>.</p></dd><dt id="-EBUSY"><span class="term"><code class="constant">-EBUSY</code></span><a class="headerlink" title="Permalink to this term" href="#-EBUSY"></a></dt><dd><p>The event loop object is not in the right
52 state (see
53 <a href="sd_event_prepare.html"><span class="citerefentry"><span class="refentrytitle">sd_event_prepare</span>(3)</span></a>
54 for an explanation of possible states).</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><p>Other errors are possible too.</p></div><div class="refsect1"><a name="idm140674379533168"></a><h2 id="Notes">Notes<a class="headerlink" title="Permalink to this headline" href="#Notes"></a></h2><p><code class="function">sd_event_run()</code> and
55 <code class="function">sd_event_loop()</code> are available
56 as a shared library, which can be compiled and linked to with the
57 <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>
58 file.</p></div><div class="refsect1"><a name="idm140674379529392"></a><h2 id="See Also">See Also<a class="headerlink" title="Permalink to this headline" href="#See%20Also"></a></h2><p>
59 <a href="systemd.html"><span class="citerefentry"><span class="refentrytitle">systemd</span>(1)</span></a>,
60 <a href="sd_event_new.html"><span class="citerefentry"><span class="refentrytitle">sd_event_new</span>(3)</span></a>,
61 <a href="sd_event_wait.html"><span class="citerefentry"><span class="refentrytitle">sd_event_wait</span>(3)</span></a>,
62 <a href="sd_event_add_io.html"><span class="citerefentry"><span class="refentrytitle">sd_event_add_io</span>(3)</span></a>,
63 <a href="sd_event_add_time.html"><span class="citerefentry"><span class="refentrytitle">sd_event_add_time</span>(3)</span></a>,
64 <a href="sd_event_add_signal.html"><span class="citerefentry"><span class="refentrytitle">sd_event_add_signal</span>(3)</span></a>,
65 <a href="sd_event_add_defer.html"><span class="citerefentry"><span class="refentrytitle">sd_event_add_defer</span>(3)</span></a>,
66 <a href="sd_event_add_exit.html"><span class="citerefentry"><span class="refentrytitle">sd_event_add_exit</span>(3)</span></a>,
67 <a href="sd_event_add_post.html"><span class="citerefentry"><span class="refentrytitle">sd_event_add_post</span>(3)</span></a>,
68 <a class="ulink" href="https://developer.gnome.org/glib/unstable/glib-The-Main-Event-Loop.html" target="_top">GLIb Main Event Loop</a>.
69 </p></div></div></body></html>