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