mirror of
				https://git.proxmox.com/git/systemd
				synced 2025-11-04 00:30:37 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			80 lines
		
	
	
		
			7.6 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			80 lines
		
	
	
		
			7.6 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>sd_watchdog_enabled</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_watchdog_enabled"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>sd_watchdog_enabled — Check whether the service manager expects watchdog keep-alive notifications from a service</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include <systemd/sd-daemon.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_watchdog_enabled</b>(</code></td><td>int <var class="pdparam">unset_environment</var>, </td></tr><tr><td> </td><td>uint64_t *<var class="pdparam">usec</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1"><a name="idm139948475415984"></a><h2 id="Description">Description<a class="headerlink" title="Permalink to this headline" href="#Description">¶</a></h2><p><code class="function">sd_watchdog_enabled()</code> may be called by
 | 
						||
    a service to detect whether the service manager expects regular
 | 
						||
    keep-alive watchdog notification events from it, and the timeout
 | 
						||
    after which the manager will act on the service if it did not get
 | 
						||
    such a notification.</p><p>If the <code class="varname">$WATCHDOG_USEC</code> environment
 | 
						||
    variable is set, and the <code class="varname">$WATCHDOG_PID</code> variable
 | 
						||
    is unset or set to the PID of the current process, the service
 | 
						||
    manager expects notifications from this process. The manager will
 | 
						||
    usually terminate a service when it does not get a notification
 | 
						||
    message within the specified time after startup and after each
 | 
						||
    previous message. It is recommended that a daemon sends a
 | 
						||
    keep-alive notification message to the service manager every half
 | 
						||
    of the time returned here. Notification messages may be sent with
 | 
						||
    <a href="sd_notify.html"><span class="citerefentry"><span class="refentrytitle">sd_notify</span>(3)</span></a>
 | 
						||
    with a message string of "<code class="literal">WATCHDOG=1</code>".</p><p>If the <em class="parameter"><code>unset_environment</code></em> parameter is
 | 
						||
    non-zero, <code class="function">sd_watchdog_enabled()</code> will unset
 | 
						||
    the <code class="varname">$WATCHDOG_USEC</code> and
 | 
						||
    <code class="varname">$WATCHDOG_PID</code> environment variables before
 | 
						||
    returning (regardless of whether the function call itself
 | 
						||
    succeeded or not). Those variables are no longer inherited by
 | 
						||
    child processes. Further calls to
 | 
						||
    <code class="function">sd_watchdog_enabled()</code> will also return with
 | 
						||
    zero.</p><p>If the <em class="parameter"><code>usec</code></em> parameter is non-NULL,
 | 
						||
    <code class="function">sd_watchdog_enabled()</code> will write the timeout
 | 
						||
    in µs for the watchdog logic to it.</p><p>To enable service supervision with the watchdog logic, use
 | 
						||
    <code class="varname">WatchdogSec=</code> in service files. See
 | 
						||
    <a href="systemd.service.html"><span class="citerefentry"><span class="refentrytitle">systemd.service</span>(5)</span></a>
 | 
						||
    for details.</p></div><div class="refsect1"><a name="idm139948479301664"></a><h2 id="Return Value">Return Value<a class="headerlink" title="Permalink to this headline" href="#Return%20Value">¶</a></h2><p>On failure, this call returns a negative errno-style error
 | 
						||
    code. If the service manager expects watchdog keep-alive
 | 
						||
    notification messages to be sent, > 0 is returned, otherwise 0
 | 
						||
    is returned. Only if the return value is > 0, the
 | 
						||
    <em class="parameter"><code>usec</code></em> parameter is valid after the
 | 
						||
    call.</p></div><div class="refsect1"><a name="idm139948479299408"></a><h2 id="Notes">Notes<a class="headerlink" title="Permalink to this headline" href="#Notes">¶</a></h2><p><a name="pkgconfig-text"></a>These APIs are implemented 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><p>Internally, this functions parses the
 | 
						||
    <code class="varname">$WATCHDOG_PID</code> and
 | 
						||
    <code class="varname">$WATCHDOG_USEC</code> environment variable. The call
 | 
						||
    will ignore these variables if <code class="varname">$WATCHDOG_PID</code>
 | 
						||
    does not contain the PID of the current process, under the
 | 
						||
    assumption that in that case, the variables were set for a
 | 
						||
    different process further up the process tree.</p></div><div class="refsect1"><a name="idm139948479295840"></a><h2 id="Environment">Environment<a class="headerlink" title="Permalink to this headline" href="#Environment">¶</a></h2><div class="variablelist"><dl class="variablelist"><dt id="$WATCHDOG_PID"><span class="term"><code class="varname">$WATCHDOG_PID</code></span><a class="headerlink" title="Permalink to this term" href="#%24WATCHDOG_PID">¶</a></dt><dd><p>Set by the system manager for supervised
 | 
						||
        process for which watchdog support is enabled, and contains
 | 
						||
        the PID of that process. See above for
 | 
						||
        details.</p></dd><dt id="$WATCHDOG_USEC"><span class="term"><code class="varname">$WATCHDOG_USEC</code></span><a class="headerlink" title="Permalink to this term" href="#%24WATCHDOG_USEC">¶</a></dt><dd><p>Set by the system manager for supervised
 | 
						||
        process for which watchdog support is enabled, and contains
 | 
						||
        the watchdog timeout in µs See above for
 | 
						||
        details.</p></dd></dl></div></div><div class="refsect1"><a name="idm139948479290944"></a><h2 id="History">History<a class="headerlink" title="Permalink to this headline" href="#History">¶</a></h2><p>The watchdog functionality and the
 | 
						||
    <code class="varname">$WATCHDOG_USEC</code> variable were added in
 | 
						||
    systemd-41.</p><p><code class="function">sd_watchdog_enabled()</code> function was
 | 
						||
    added in systemd-209. Since that version the
 | 
						||
    <code class="varname">$WATCHDOG_PID</code> variable is also set.</p></div><div class="refsect1"><a name="idm139948479287856"></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-daemon.html"><span class="citerefentry"><span class="refentrytitle">sd-daemon</span>(3)</span></a>,
 | 
						||
      <a href="daemon.html"><span class="citerefentry"><span class="refentrytitle">daemon</span>(7)</span></a>,
 | 
						||
      <a href="systemd.service.html"><span class="citerefentry"><span class="refentrytitle">systemd.service</span>(5)</span></a>,
 | 
						||
      <a href="sd_notify.html"><span class="citerefentry"><span class="refentrytitle">sd_notify</span>(3)</span></a>
 | 
						||
    </p></div></div></body></html>
 |