]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/sd_event_set_watchdog.xml
tree-wide: remove Lennart's copyright lines
[thirdparty/systemd.git] / man / sd_event_set_watchdog.xml
CommitLineData
dc83f27a
LP
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<!--
572eb058 6 SPDX-License-Identifier: LGPL-2.1+
dc83f27a
LP
7-->
8
9<refentry id="sd_event_set_watchdog" xmlns:xi="http://www.w3.org/2001/XInclude">
10
11 <refentryinfo>
12 <title>sd_event_set_watchdog</title>
13 <productname>systemd</productname>
14
15 <authorgroup>
16 <author>
17 <contrib>Developer</contrib>
18 <firstname>Lennart</firstname>
19 <surname>Poettering</surname>
20 <email>lennart@poettering.net</email>
21 </author>
22 </authorgroup>
23 </refentryinfo>
24
25 <refmeta>
26 <refentrytitle>sd_event_set_watchdog</refentrytitle>
27 <manvolnum>3</manvolnum>
28 </refmeta>
29
30 <refnamediv>
31 <refname>sd_event_set_watchdog</refname>
32 <refname>sd_event_get_watchdog</refname>
33
34 <refpurpose>Enable event loop watchdog support</refpurpose>
35 </refnamediv>
36
37 <refsynopsisdiv>
38 <funcsynopsis>
39 <funcsynopsisinfo>#include &lt;systemd/sd-event.h&gt;</funcsynopsisinfo>
40
41 <funcprototype>
42 <funcdef>int <function>sd_event_set_watchdog</function></funcdef>
43 <paramdef>sd_event *<parameter>event</parameter></paramdef>
44 <paramdef>int b</paramdef>
45 </funcprototype>
46
47 <funcprototype>
48 <funcdef>int <function>sd_event_get_watchdog</function></funcdef>
49 <paramdef>sd_event *<parameter>event</parameter></paramdef>
50 </funcprototype>
51
52 </funcsynopsis>
53 </refsynopsisdiv>
54
55 <refsect1>
56 <title>Description</title>
57
58 <para><function>sd_event_set_watchdog()</function> may be used to
59 enable or disable automatic watchdog notification support in the
60 event loop object specified in the <parameter>event</parameter>
61 parameter. Specifically, depending on the <parameter>b</parameter>
62 boolean argument this will make sure the event loop wakes up in
63 regular intervals and sends watchdog notification messages to the
64 service manager, if this was requested by the service
65 manager. Watchdog support is determined with
66 <citerefentry><refentrytitle>sd_watchdog_enabled</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
67 and watchdog messages are sent with
68 <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>. See
69 the <varname>WatchdogSec=</varname> setting in
70 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>
71 for details on how to enable watchdog support for a service and
72 the protocol used. The wake-up interval is chosen as half the
73 watchdog timeout declared by the service manager via the
74 <varname>$WATCHDOG_USEC</varname> environment variable. If the
75 service manager did not request watchdog notifications, or if the
76 process was not invoked by the service manager this call with a
77 true <parameter>b</parameter> parameter executes no
78 operation. Passing a false <parameter>b</parameter> parameter will
79 disable the automatic sending of watchdog notification messages if
80 it was enabled before. Newly allocated event loop objects have
81 this feature disabled.</para>
82
83 <para>The first watchdog notification message is sent immediately
84 when <function>set_event_set_watchdog()</function> is invoked with
85 a true <parameter>b</parameter> parameter.</para>
86
87 <para>The watchdog logic is designed to allow the service manager
88 to automatically detect services that ceased processing of
89 incoming events, and thus appear "hung". Watchdog notifications
90 are sent out only at the beginning of each event loop
91 iteration. If an event source dispatch function blocks for an
92 excessively long time and does not return execution to the event
93 loop quickly, this might hence cause the notification message to
94 be delayed, and possibly result in abnormal program termination,
95 as configured in the service unit file.</para>
96
97 <para><function>sd_event_get_watchdog()</function> may be used to
98 determine whether watchdog support was previously requested by a
99 call to <function>sd_event_set_watchdog()</function> with a true
100 <parameter>b</parameter> parameter and successfully
101 enabled.</para>
102 </refsect1>
103
104 <refsect1>
105 <title>Return Value</title>
106
107 <para>On success, <function>sd_event_set_watchdog()</function> and
108 <function>sd_event_get_watchdog()</function> return a non-zero
109 positive integer if the service manager requested watchdog support
110 and watchdog support was successfully enabled. They return zero if
111 the service manager did not request watchdog support, or if
112 watchdog support was explicitly disabled with a false
113 <parameter>b</parameter> parameter. On failure, they return a
114 negative errno-style error
115 code.</para>
116 </refsect1>
117
118 <refsect1>
119 <title>Errors</title>
120
121 <para>Returned errors may indicate the following problems:</para>
122
123 <variablelist>
124
125 <varlistentry>
126 <term><constant>-ECHILD</constant></term>
127
128 <listitem><para>The event loop has been created in a different process.</para></listitem>
129 </varlistentry>
130
131 <varlistentry>
132 <term><constant>-EINVAL</constant></term>
133
134 <listitem><para>The passed event loop object was invalid.</para></listitem>
135 </varlistentry>
136
137 </variablelist>
138 </refsect1>
139
140 <xi:include href="libsystemd-pkgconfig.xml" />
141
142 <refsect1>
143 <title>See Also</title>
144
145 <para>
146 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
147 <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
148 <citerefentry><refentrytitle>sd_event_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
149 <citerefentry><refentrytitle>sd_event_add_io</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
150 <citerefentry><refentrytitle>sd_event_add_time</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
151 <citerefentry><refentrytitle>sd_event_add_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
152 <citerefentry><refentrytitle>sd_event_add_child</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
153 <citerefentry><refentrytitle>sd_event_add_defer</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
154 <citerefentry><refentrytitle>sd_event_add_post</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
155 <citerefentry><refentrytitle>sd_event_add_exit</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
156 <citerefentry><refentrytitle>sd_watchdog_enabled</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
157 <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
158 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>
159 </para>
160 </refsect1>
161
162</refentry>