mirror of
https://git.proxmox.com/git/systemd
synced 2025-06-02 07:34:33 +00:00
76 lines
9.0 KiB
HTML
76 lines
9.0 KiB
HTML
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>sd_event_add_child</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_child"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>sd_event_add_child, sd_event_source_get_child_pid — Add a child state change event source to an event loop</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include <systemd/sd-bus.h></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_child</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>pid_t <var class="pdparam">pid</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">options</var>, </td></tr><tr><td> </td><td>sd_event_child_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_child_handler_t</b>)(</code></td><td>sd_event_source *<var class="pdparam">s</var>, </td></tr><tr><td> </td><td>const siginfo_t *<var class="pdparam">si</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_source_get_child_pid</b>(</code></td><td>sd_event_source *<var class="pdparam">source</var>, </td></tr><tr><td> </td><td>pid_t *<var class="pdparam">pid</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1"><a name="idm140121348202000"></a><h2 id="Description">Description<a class="headerlink" title="Permalink to this headline" href="#Description">¶</a></h2><p><code class="function">sd_event_add_child()</code> adds a new child
|
||
state change event source 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
|
||
<em class="parameter"><code>pid</code></em> parameter specifies the process to
|
||
watch. The <em class="parameter"><code>handler</code></em> must reference a
|
||
function to call when the process changes state. The handler
|
||
function will be passed the <em class="parameter"><code>userdata</code></em>
|
||
pointer, which may be chosen freely by the caller. The handler
|
||
also receives a pointer to a <span class="structname">const
|
||
siginfo_t</span> structure containing the information about
|
||
the event. The <em class="parameter"><code>options</code></em> parameter determines
|
||
which state changes will be watched for. It must contain an OR-ed
|
||
mask of <code class="constant">WEXITED</code> (watch for the child
|
||
terminating), <code class="constant">WSTOPPED</code> (watch for the child
|
||
being stopped by a signal), and <code class="constant">WCONTINUED</code>
|
||
(watch for the child being resumed by a signal). See
|
||
<a href="http://man7.org/linux/man-pages/man2/waitid.2.html"><span class="citerefentry"><span class="refentrytitle">waitid</span>(2)</span></a>
|
||
for further information.</p><p>Only a single handler may be installed for a specific
|
||
child. The handler is enabled
|
||
for a single event (<code class="constant">SD_EVENT_ONESHOT</code>),
|
||
but this may be
|
||
changed with
|
||
<a href="sd_event_source_set_enabled.html"><span class="citerefentry"><span class="refentrytitle">sd_event_source_set_enabled</span>(3)</span></a>.
|
||
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><p><code class="function">sd_event_source_get_child_pid()</code>
|
||
retrieves the configured <em class="parameter"><code>pid</code></em> of a child
|
||
state change event source created previously with
|
||
<code class="function">sd_event_add_child()</code>. It takes the event
|
||
source object as the <em class="parameter"><code>source</code></em> parameter and a
|
||
pointer to <span class="type">pid_t</span> to return the result in.
|
||
</p></div><div class="refsect1"><a name="idm140121352089856"></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.</p></div><div class="refsect1"><a name="idm140121352088528"></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. This includes
|
||
specifying an empty mask in <em class="parameter"><code>options</code></em> or a mask
|
||
which contains values different than a combination of
|
||
<code class="constant">WEXITED</code>, <code class="constant">WSTOPPED</code>, and
|
||
<code class="constant">WCONTINUED</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>An handler is already installed for this
|
||
child.</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="idm140121352070400"></a><h2 id="Notes">Notes<a class="headerlink" title="Permalink to this headline" href="#Notes">¶</a></h2><p><code class="function">sd_event_add_child()</code> and the other 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="idm140121352066864"></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_defer.html"><span class="citerefentry"><span class="refentrytitle">sd_event_add_defer</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>
|