~ubuntu-branches/ubuntu/trusty/systemd/trusty

« back to all changes in this revision

Viewing changes to man/sd_booted.html

Tags: upstream-202
Import upstream version 202

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
  <a href="systemd.directives.html">Directives </a>·
3
3
  <a href="../python-systemd/index.html">Python </a>·
4
4
  <a href="../libudev/index.html">libudev </a>·
5
 
  <a href="../libudev/index.html">gudev </a><hr><div class="refentry"><a name="sd_booted"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>sd_booted — Test whether the system is running the systemd init system</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include &lt;systemd/sd-daemon.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_booted</b>(</code></td><td>void<code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1"><a name="idp3967296"></a><h2>Description</h2><p><code class="function">sd_booted()</code> checks whether
6
 
                the system was booted up using the systemd init system.</p></div><div class="refsect1"><a name="idp3969040"></a><h2>Return Value</h2><p>On failure, this call returns a negative
 
5
  <a href="../libudev/index.html">gudev </a><span style="float:right">systemd 202</span><hr><div class="refentry"><a name="sd_booted"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>sd_booted — Test whether the system is running the systemd init system</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include &lt;systemd/sd-daemon.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_booted</b>(</code></td><td>void<code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1"><a name="idp194000"></a><h2>Description</h2><p><code class="function">sd_booted()</code> checks whether
 
6
                the system was booted up using the systemd init system.</p></div><div class="refsect1"><a name="idp196672"></a><h2>Return Value</h2><p>On failure, this call returns a negative
7
7
                errno-style error code. If the system was booted up
8
8
                with systemd as init system, this call returns a
9
 
                positive return value, zero otherwise.</p></div><div class="refsect1"><a name="idp3970464"></a><h2>Notes</h2><p>This function is provided by the reference
 
9
                positive return value, zero otherwise.</p></div><div class="refsect1"><a name="idp124960"></a><h2>Notes</h2><p>This function is provided by the reference
10
10
                implementation of APIs for new-style daemons and
11
11
                distributed with the systemd package. The algorithm it
12
12
                implements is simple, and can easily be reimplemented
13
13
                in daemons if it is important to support this
14
14
                interface without using the reference
15
15
                implementation.</p><p>Internally, this function checks whether the
16
 
                <code class="filename">/sys/fs/cgroup/systemd</code> virtual file
17
 
                system is mounted, by comparing the st_dev value of
18
 
                the <code class="function">stat()</code> data of
19
 
                <code class="filename">/sys/fs/cgroup</code> and
20
 
                <code class="filename">/sys/fs/cgroup/systemd</code>.</p><p>For details about the algorithm check the
 
16
                directory <code class="filename">/run/systemd/system/</code>
 
17
                exists. A simple check like this can also be
 
18
                implemented trivially in shell or any other
 
19
                language.</p><p>For details about the algorithm check the
21
20
                liberally licensed reference implementation sources:
22
21
                <a class="ulink" href="http://cgit.freedesktop.org/systemd/systemd/plain/src/libsystemd-daemon/sd-daemon.c" target="_top">http://cgit.freedesktop.org/systemd/systemd/plain/src/libsystemd-daemon/sd-daemon.c</a>
23
22
                and <a class="ulink" href="http://cgit.freedesktop.org/systemd/systemd/plain/src/systemd/sd-daemon.h" target="_top">http://cgit.freedesktop.org/systemd/systemd/plain/src/systemd/sd-daemon.h</a></p><p><code class="function">sd_booted()</code> is implemented
35
34
                <a href="sd-daemon.html"><span class="citerefentry"><span class="refentrytitle">sd-daemon</span>(3)</span></a>.</p><p>If the reference implementation is used as
36
35
                drop-in files and -DDISABLE_SYSTEMD is set during
37
36
                compilation this function will always return 0 and
38
 
                otherwise become a NOP.</p></div><div class="refsect1"><a name="idp26128"></a><h2>See Also</h2><p>
 
37
                otherwise become a NOP.</p></div><div class="refsect1"><a name="idp3971152"></a><h2>See Also</h2><p>
39
38
                        <a href="systemd.html"><span class="citerefentry"><span class="refentrytitle">systemd</span>(1)</span></a>,
40
39
                        <a href="sd-daemon.html"><span class="citerefentry"><span class="refentrytitle">sd-daemon</span>(3)</span></a>
41
40
                </p></div></div></body></html>