dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering<?xml version='1.0'?> <!--*- Mode: nxml; nxml-child-indent: 2; indent-tabs-mode: nil -*-->
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering This file is part of systemd.
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering Copyright 2015 Lennart Poettering
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering systemd is free software; you can redistribute it and/or modify it
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering under the terms of the GNU Lesser General Public License as published by
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering (at your option) any later version.
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering systemd is distributed in the hope that it will be useful, but
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering Lesser General Public License for more details.
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering You should have received a copy of the GNU Lesser General Public License
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering<refentry id="sd_event_set_watchdog" xmlns:xi="http://www.w3.org/2001/XInclude">
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <refentryinfo>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering </authorgroup>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering </refentryinfo>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <refentrytitle>sd_event_set_watchdog</refentrytitle>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <refpurpose>Enable event loop watchdog support</refpurpose>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <refsynopsisdiv>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <funcsynopsis>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <funcsynopsisinfo>#include <systemd/sd-event.h></funcsynopsisinfo>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <funcprototype>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <funcdef>int <function>sd_event_set_watchdog</function></funcdef>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <paramdef>sd_event *<parameter>event</parameter></paramdef>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering </funcprototype>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <funcprototype>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <funcdef>int <function>sd_event_get_watchdog</function></funcdef>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <paramdef>sd_event *<parameter>event</parameter></paramdef>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering </funcprototype>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering </funcsynopsis>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering </refsynopsisdiv>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <para><function>sd_event_set_watchdog()</function> may be used to
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering enable or disable automatic watchdog notification support in the
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering event loop object specified in the <parameter>event</parameter>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering parameter. Specifically, depending on the <parameter>b</parameter>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering boolean argument this will make sure the event loop wakes up in
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering regular intervals and sends watchdog notification messages to the
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering service manager, if this was requested by the service
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering manager. Watchdog support is determined with
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <citerefentry><refentrytitle>sd_watchdog_enabled</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering and watchdog messages are sent with
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>. See
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering the <varname>WatchdogSec=</varname> setting in
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering for details on how to enable watchdog support for a service and
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering the protocol used. The wake-up interval is chosen as half the
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering watchdog timeout declared by the service manager via the
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <varname>$WATCHDOG_USEC</varname> environment variable. If the
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering service manager did not request watchdog notifications, or if the
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering process was not invoked by the service manager this call with a
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering true <parameter>b</parameter> parameter executes no
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering operation. Passing a false <parameter>b</parameter> parameter will
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering disable the automatic sending of watchdog notification messages if
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering it was enabled before. Newly allocated event loop objects have
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering this feature disabled.</para>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <para>The first watchdog notification message is sent immediately
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering when <function>set_event_set_watchdog()</function> is invoked with
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering a true <parameter>b</parameter> parameter.</para>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <para>The watchdog logic is designed to allow the service manager
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering to automatically detect services that ceased processing of
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering incoming events, and thus appear "hung". Watchdog notifications
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering are sent out only at the beginning of each event loop
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering iteration. If an event source dispatch function blocks for an
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering excessively long time and does not return execution to the event
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering loop quickly, this might hence cause the notification message to
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering be delayed, and possibly result in abnormal program termination,
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering as configured in the service unit file.</para>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <para><function>sd_event_get_watchdog()</function> may be used to
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering determine whether watchdog support was previously requested by a
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering call to <function>sd_event_set_watchdog()</function> with a true
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <parameter>b</parameter> parameter and successfully
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering enabled.</para>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <para>On success, <function>sd_event_set_watchdog()</function> and
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <function>sd_event_get_watchdog()</function> return a non-zero
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering positive integer if the service manager requested watchdog support
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering and watchdog support was successfully enabled. They return zero if
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering the service manager did not request watchdog support, or if
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering watchdog support was explicitly disabled with a false
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <parameter>b</parameter> parameter. On failure, they return a
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering negative errno-style error
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <para>Returned errors may indicate the following problems:</para>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <variablelist>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <varlistentry>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <term><constant>-ECHILD</constant></term>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <listitem><para>The event loop has been created in a different process.</para></listitem>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering </varlistentry>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <varlistentry>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <term><constant>-EINVAL</constant></term>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <listitem><para>The passed event loop object was invalid.</para></listitem>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering </varlistentry>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering </variablelist>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <xi:include href="libsystemd-pkgconfig.xml" />
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <citerefentry><refentrytitle>sd_event_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <citerefentry><refentrytitle>sd_event_add_io</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <citerefentry><refentrytitle>sd_event_add_time</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <citerefentry><refentrytitle>sd_event_add_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <citerefentry><refentrytitle>sd_event_add_child</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <citerefentry><refentrytitle>sd_event_add_defer</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <citerefentry><refentrytitle>sd_event_add_post</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <citerefentry><refentrytitle>sd_event_add_exit</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <citerefentry><refentrytitle>sd_watchdog_enabled</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>