chiark / gitweb /
tree-wide: remove Lennart's copyright lines
[elogind.git] / man / sd_watchdog_enabled.xml
1 <?xml version='1.0'?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3   "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4
5 <!--
6   SPDX-License-Identifier: LGPL-2.1+
7 -->
8
9 <refentry id="sd_watchdog_enabled"
10   xmlns:xi="http://www.w3.org/2001/XInclude">
11
12   <refentryinfo>
13     <title>sd_watchdog_enabled</title>
14     <productname>elogind</productname>
15
16     <authorgroup>
17       <author>
18         <contrib>Developer</contrib>
19         <firstname>Lennart</firstname>
20         <surname>Poettering</surname>
21         <email>lennart@poettering.net</email>
22       </author>
23     </authorgroup>
24   </refentryinfo>
25
26   <refmeta>
27     <refentrytitle>sd_watchdog_enabled</refentrytitle>
28     <manvolnum>3</manvolnum>
29   </refmeta>
30
31   <refnamediv>
32     <refname>sd_watchdog_enabled</refname>
33     <refpurpose>Check whether the service manager expects watchdog keep-alive notifications from a service</refpurpose>
34   </refnamediv>
35
36   <refsynopsisdiv>
37     <funcsynopsis>
38       <funcsynopsisinfo>#include &lt;elogind/sd-daemon.h&gt;</funcsynopsisinfo>
39
40       <funcprototype>
41         <funcdef>int <function>sd_watchdog_enabled</function></funcdef>
42         <paramdef>int <parameter>unset_environment</parameter></paramdef>
43         <paramdef>uint64_t *<parameter>usec</parameter></paramdef>
44       </funcprototype>
45     </funcsynopsis>
46   </refsynopsisdiv>
47
48   <refsect1>
49     <title>Description</title>
50     <para><function>sd_watchdog_enabled()</function> may be called by
51     a service to detect whether the service manager expects regular
52     keep-alive watchdog notification events from it, and the timeout
53     after which the manager will act on the service if it did not get
54     such a notification.</para>
55
56     <para>If the <varname>$WATCHDOG_USEC</varname> environment
57     variable is set, and the <varname>$WATCHDOG_PID</varname> variable
58     is unset or set to the PID of the current process, the service
59     manager expects notifications from this process. The manager will
60     usually terminate a service when it does not get a notification
61     message within the specified time after startup and after each
62     previous message. It is recommended that a daemon sends a
63     keep-alive notification message to the service manager every half
64     of the time returned here. Notification messages may be sent with
65     <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>
66     with a message string of <literal>WATCHDOG=1</literal>.</para>
67
68     <para>If the <parameter>unset_environment</parameter> parameter is
69     non-zero, <function>sd_watchdog_enabled()</function> will unset
70     the <varname>$WATCHDOG_USEC</varname> and
71     <varname>$WATCHDOG_PID</varname> environment variables before
72     returning (regardless of whether the function call itself
73     succeeded or not). Those variables are no longer inherited by
74     child processes. Further calls to
75     <function>sd_watchdog_enabled()</function> will also return with
76     zero.</para>
77
78     <para>If the <parameter>usec</parameter> parameter is non-NULL,
79     <function>sd_watchdog_enabled()</function> will write the timeout
80     in µs for the watchdog logic to it.</para>
81
82     <para>To enable service supervision with the watchdog logic, use
83     <varname>WatchdogSec=</varname> in service files. See
84     <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>
85     for details.</para>
86
87     <para>Use
88     <citerefentry><refentrytitle>sd_event_set_watchdog</refentrytitle><manvolnum>3</manvolnum></citerefentry>
89     to enable automatic watchdog support in
90     <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>-based event loops.</para>
91   </refsect1>
92
93   <refsect1>
94     <title>Return Value</title>
95
96     <para>On failure, this call returns a negative errno-style error
97     code. If the service manager expects watchdog keep-alive
98     notification messages to be sent, &gt; 0 is returned, otherwise 0
99     is returned. Only if the return value is &gt; 0, the
100     <parameter>usec</parameter> parameter is valid after the
101     call.</para>
102   </refsect1>
103
104   <refsect1>
105     <title>Notes</title>
106
107     <xi:include href="libelogind-pkgconfig.xml" xpointer="pkgconfig-text"/>
108
109     <para>Internally, this function parses the
110     <varname>$WATCHDOG_PID</varname> and
111     <varname>$WATCHDOG_USEC</varname> environment variable. The call
112     will ignore these variables if <varname>$WATCHDOG_PID</varname>
113     does not contain the PID of the current process, under the
114     assumption that in that case, the variables were set for a
115     different process further up the process tree.</para>
116   </refsect1>
117
118   <refsect1>
119     <title>Environment</title>
120
121     <variablelist class='environment-variables'>
122       <varlistentry>
123         <term><varname>$WATCHDOG_PID</varname></term>
124
125         <listitem><para>Set by the system manager for supervised
126         process for which watchdog support is enabled, and contains
127         the PID of that process. See above for
128         details.</para></listitem>
129       </varlistentry>
130
131       <varlistentry>
132         <term><varname>$WATCHDOG_USEC</varname></term>
133
134         <listitem><para>Set by the system manager for supervised
135         process for which watchdog support is enabled, and contains
136         the watchdog timeout in µs. See above for
137         details.</para></listitem>
138       </varlistentry>
139     </variablelist>
140   </refsect1>
141
142   <refsect1>
143     <title>See Also</title>
144     <para>
145       <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
146       <citerefentry><refentrytitle>sd-daemon</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
147       <citerefentry><refentrytitle>daemon</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
148       <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
149       <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
150       <citerefentry><refentrytitle>sd_event_set_watchdog</refentrytitle><manvolnum>3</manvolnum></citerefentry>
151     </para>
152   </refsect1>
153
154 </refentry>