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