summaryrefslogtreecommitdiff
path: root/man/sd_event_loop.html
blob: a4452a6b139bcb81a6ae9f89e152cbd52d69f86e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<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>
    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>·

  <span style="float:right">systemd 221</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="idm48010812915968"></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
    iteration of the event loop of libsystemd. This function waits
    until an event to process is available and dispatches a handler
    for it. Parameter <em class="parameter"><code>timeout</code></em> specifices the
    maximum time (in microseconds) to wait. <code class="constant">(uint64_t)
    -1</code> may be used to specify an infinite timeout.</p><p><code class="function">sd_event_loop</code> runs
    <code class="function">sd_event_wait</code> in a loop with a timeout of
    infinity. This makes it suitable for the main event loop of a
    program.</p><p>The event loop object <em class="parameter"><code>event</code></em> is
    created with
    <code class="function">sd_event_new</code>.
    Events to wait for and their handlers can be registered with
    <code class="function">sd_event_add_time</code>,
    <code class="function">sd_event_add_child</code>,
    <code class="function">sd_event_add_signal</code>,
    <code class="function">sd_event_add_defer</code>,
    <code class="function">sd_event_add_exit</code>,
    and
    <code class="function">sd_event_add_post</code>.
    </p><p>For more fine-grained control,
    <code class="function">sd_event_prepare</code>,
    <code class="function">sd_event_wait</code>, and
    <code class="function">sd_event_dispatch</code> may be used. Along with
    <code class="function">sd_event_get_fd</code>, those functions make it
    possible to integrate the libsystemd loop inside of another event
    loop.</p></div><div class="refsect1"><a name="idm48010812903104"></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.
    On failure, they return a negative errno-style error code.
    <code class="function">sd_event_run</code> returns 0 if the event loop is
    finished, and a positive value if it can be continued.</p></div><div class="refsect1"><a name="idm48010812901072"></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
        <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
        state (see
        <a href="sd_event_prepare.html"><span class="citerefentry"><span class="refentrytitle">sd_event_prepare</span>(3)</span></a>
        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="idm48010812891744"></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
    <code class="function">sd_event_loop()</code> 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="idm48010812887968"></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_new.html"><span class="citerefentry"><span class="refentrytitle">sd_event_new</span>(3)</span></a>,
      <a href="sd_event_wait.html"><span class="citerefentry"><span class="refentrytitle">sd_event_wait</span>(3)</span></a>,
      <a href="sd_event_add_io.html"><span class="citerefentry"><span class="refentrytitle">sd_event_add_io</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_defer.html"><span class="citerefentry"><span class="refentrytitle">sd_event_add_defer</span>(3)</span></a>,
      <a href="sd_event_add_exit.html"><span class="citerefentry"><span class="refentrytitle">sd_event_add_exit</span>(3)</span></a>,
      <a href="sd_event_add_post.html"><span class="citerefentry"><span class="refentrytitle">sd_event_add_post</span>(3)</span></a>,
      <a class="ulink" href="https://developer.gnome.org/glib/unstable/glib-The-Main-Event-Loop.html" target="_top">GLIb Main Event Loop</a>.
    </p></div></div></body></html>