chiark / gitweb /
Prep v229.5: Make musl-libc utmp/wtmp stubs visible.
[elogind.git] / man / sd_event_set_watchdog.xml
1 <?xml version='1.0'?> <!--*- Mode: nxml; nxml-child-indent: 2; indent-tabs-mode: nil -*-->
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   This file is part of elogind.
7
8   Copyright 2015 Lennart Poettering
9
10   elogind is free software; you can redistribute it and/or modify it
11   under the terms of the GNU Lesser General Public License as published by
12   the Free Software Foundation; either version 2.1 of the License, or
13   (at your option) any later version.
14
15   elogind is distributed in the hope that it will be useful, but
16   WITHOUT ANY WARRANTY; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18   Lesser General Public License for more details.
19
20   You should have received a copy of the GNU Lesser General Public License
21   along with elogind; If not, see <http://www.gnu.org/licenses/>.
22 -->
23
24 <refentry id="sd_event_set_watchdog" xmlns:xi="http://www.w3.org/2001/XInclude">
25
26   <refentryinfo>
27     <title>sd_event_set_watchdog</title>
28     <productname>elogind</productname>
29
30     <authorgroup>
31       <author>
32         <contrib>Developer</contrib>
33         <firstname>Lennart</firstname>
34         <surname>Poettering</surname>
35         <email>lennart@poettering.net</email>
36       </author>
37     </authorgroup>
38   </refentryinfo>
39
40   <refmeta>
41     <refentrytitle>sd_event_set_watchdog</refentrytitle>
42     <manvolnum>3</manvolnum>
43   </refmeta>
44
45   <refnamediv>
46     <refname>sd_event_set_watchdog</refname>
47     <refname>sd_event_get_watchdog</refname>
48
49     <refpurpose>Enable event loop watchdog support</refpurpose>
50   </refnamediv>
51
52   <refsynopsisdiv>
53     <funcsynopsis>
54       <funcsynopsisinfo>#include &lt;elogind/sd-event.h&gt;</funcsynopsisinfo>
55
56       <funcprototype>
57         <funcdef>int <function>sd_event_set_watchdog</function></funcdef>
58         <paramdef>sd_event *<parameter>event</parameter></paramdef>
59         <paramdef>int b</paramdef>
60       </funcprototype>
61
62       <funcprototype>
63         <funcdef>int <function>sd_event_get_watchdog</function></funcdef>
64         <paramdef>sd_event *<parameter>event</parameter></paramdef>
65       </funcprototype>
66
67     </funcsynopsis>
68   </refsynopsisdiv>
69
70   <refsect1>
71     <title>Description</title>
72
73     <para><function>sd_event_set_watchdog()</function> may be used to
74     enable or disable automatic watchdog notification support in the
75     event loop object specified in the <parameter>event</parameter>
76     parameter. Specifically, depending on the <parameter>b</parameter>
77     boolean argument this will make sure the event loop wakes up in
78     regular intervals and sends watchdog notification messages to the
79     service manager, if this was requested by the service
80     manager. Watchdog support is determined with
81     <citerefentry><refentrytitle>sd_watchdog_enabled</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
82     and watchdog messages are sent with
83     <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>. See
84     the <varname>WatchdogSec=</varname> setting in
85     <citerefentry><refentrytitle>elogind.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>
86     for details on how to enable watchdog support for a service and
87     the protocol used. The wake-up interval is chosen as half the
88     watchdog timeout declared by the service manager via the
89     <varname>$WATCHDOG_USEC</varname> environment variable. If the
90     service manager did not request watchdog notifications, or if the
91     process was not invoked by the service manager this call with a
92     true <parameter>b</parameter> parameter executes no
93     operation. Passing a false <parameter>b</parameter> parameter will
94     disable the automatic sending of watchdog notification messages if
95     it was enabled before. Newly allocated event loop objects have
96     this feature disabled.</para>
97
98     <para>The first watchdog notification message is sent immediately
99     when <function>set_event_set_watchdog()</function> is invoked with
100     a true <parameter>b</parameter> parameter.</para>
101
102     <para>The watchdog logic is designed to allow the service manager
103     to automatically detect services that ceased processing of
104     incoming events, and thus appear "hung". Watchdog notifications
105     are sent out only at the beginning of each event loop
106     iteration. If an event source dispatch function blocks for an
107     excessively long time and does not return execution to the event
108     loop quickly, this might hence cause the notification message to
109     be delayed, and possibly result in abnormal program termination,
110     as configured in the service unit file.</para>
111
112     <para><function>sd_event_get_watchdog()</function> may be used to
113     determine whether watchdog support was previously requested by a
114     call to <function>sd_event_set_watchdog()</function> with a true
115     <parameter>b</parameter> parameter and successfully
116     enabled.</para>
117   </refsect1>
118
119   <refsect1>
120     <title>Return Value</title>
121
122     <para>On success, <function>sd_event_set_watchdog()</function> and
123     <function>sd_event_get_watchdog()</function> return a non-zero
124     positive integer if the service manager requested watchdog support
125     and watchdog support was successfully enabled. They return zero if
126     the service manager did not request watchdog support, or if
127     watchdog support was explicitly disabled with a false
128     <parameter>b</parameter> parameter. On failure, they return a
129     negative errno-style error
130     code.</para>
131   </refsect1>
132
133   <refsect1>
134     <title>Errors</title>
135
136     <para>Returned errors may indicate the following problems:</para>
137
138     <variablelist>
139
140       <varlistentry>
141         <term><constant>-ECHILD</constant></term>
142
143         <listitem><para>The event loop has been created in a different process.</para></listitem>
144       </varlistentry>
145
146       <varlistentry>
147         <term><constant>-EINVAL</constant></term>
148
149         <listitem><para>The passed event loop object was invalid.</para></listitem>
150       </varlistentry>
151
152     </variablelist>
153   </refsect1>
154
155   <xi:include href="libelogind-pkgconfig.xml" />
156
157   <refsect1>
158     <title>See Also</title>
159
160     <para>
161       <citerefentry><refentrytitle>elogind</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
162       <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
163       <citerefentry><refentrytitle>sd_event_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
164       <citerefentry><refentrytitle>sd_event_add_io</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
165       <citerefentry><refentrytitle>sd_event_add_time</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
166       <citerefentry><refentrytitle>sd_event_add_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
167       <citerefentry><refentrytitle>sd_event_add_child</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
168       <citerefentry><refentrytitle>sd_event_add_defer</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
169       <citerefentry><refentrytitle>sd_event_add_post</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
170       <citerefentry><refentrytitle>sd_event_add_exit</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
171       <citerefentry><refentrytitle>sd_watchdog_enabled</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
172       <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
173       <citerefentry><refentrytitle>elogind.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>
174     </para>
175   </refsect1>
176
177 </refentry>