171 lines
5.0 KiB
HTML
171 lines
5.0 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of SD_WATCHDOG_ENABLED</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>SD_WATCHDOG_ENABLED</H1>
|
|
Section: sd_watchdog_enabled (3)<BR>Updated: <BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
sd_watchdog_enabled - Check whether the service manager expects watchdog keep-alive notifications from a service
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<P>
|
|
<B>
|
|
</B><PRE>
|
|
#include <<A HREF="file:///usr/include/systemd/sd-daemon.h">systemd/sd-daemon.h</A>>
|
|
</PRE>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="1">
|
|
<B>int sd_watchdog_enabled(int </B><I>unset_environment</I><B>, uint64_t *</B><I>usec</I><B>);</B>
|
|
|
|
</DL>
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
<P>
|
|
|
|
<B>sd_watchdog_enabled()</B>
|
|
<DD>may be called by a service to detect whether the service manager expects regular keep-alive watchdog notification events from it, and the timeout after which the manager will act on the service if it did not get such a notification.
|
|
<P>
|
|
|
|
If the
|
|
<I>$WATCHDOG_USEC</I>
|
|
environment variable is set, and the
|
|
<I>$WATCHDOG_PID</I>
|
|
variable is unset or set to the PID of the current process, the service manager expects notifications from this process. The manager will usually terminate a service when it does not get a notification message within the specified time after startup and after each previous message. It is recommended that a daemon sends a keep-alive notification message to the service manager every half of the time returned here. Notification messages may be sent with
|
|
<B><A HREF="/cgi-bin/man/man2html?3+sd_notify">sd_notify</A></B>(3)
|
|
with a message string of
|
|
"WATCHDOG=1".
|
|
<P>
|
|
|
|
If the
|
|
<I>unset_environment</I>
|
|
parameter is non-zero,
|
|
<B>sd_watchdog_enabled()</B>
|
|
will unset the
|
|
<I>$WATCHDOG_USEC</I>
|
|
and
|
|
<I>$WATCHDOG_PID</I>
|
|
environment variables before returning (regardless of whether the function call itself succeeded or not). Those variables are no longer inherited by child processes. Further calls to
|
|
<B>sd_watchdog_enabled()</B>
|
|
will also return with zero.
|
|
<P>
|
|
|
|
If the
|
|
<I>usec</I>
|
|
parameter is non-NULL,
|
|
<B>sd_watchdog_enabled()</B>
|
|
will write the timeout in µs for the watchdog logic to it.
|
|
<P>
|
|
|
|
To enable service supervision with the watchdog logic, use
|
|
<I>WatchdogSec=</I>
|
|
in service files. See
|
|
<B><A HREF="/cgi-bin/man/man2html?5+systemd.service">systemd.service</A></B>(5)
|
|
for details.
|
|
<P>
|
|
|
|
Use
|
|
<B><A HREF="/cgi-bin/man/man2html?3+sd_event_set_watchdog">sd_event_set_watchdog</A></B>(3)
|
|
to enable automatic watchdog support in
|
|
<B><A HREF="/cgi-bin/man/man2html?3+sd-event">sd-event</A></B>(3)-based event loops.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>RETURN VALUE</H2>
|
|
|
|
<P>
|
|
|
|
On failure, this call returns a negative errno-style error code. If the service manager expects watchdog keep-alive notification messages to be sent, > 0 is returned, otherwise 0 is returned. Only if the return value is > 0, the
|
|
<I>usec</I>
|
|
parameter is valid after the call.
|
|
<A NAME="lbAF"> </A>
|
|
<H2>NOTES</H2>
|
|
|
|
<P>
|
|
|
|
These APIs are implemented as a shared library, which can be compiled and linked to with the
|
|
<B>libsystemd</B> <B><A HREF="/cgi-bin/man/man2html?1+pkg-config">pkg-config</A></B>(1)
|
|
file.
|
|
<P>
|
|
|
|
Internally, this function parses the
|
|
<I>$WATCHDOG_PID</I>
|
|
and
|
|
<I>$WATCHDOG_USEC</I>
|
|
environment variable. The call will ignore these variables if
|
|
<I>$WATCHDOG_PID</I>
|
|
does not contain the PID of the current process, under the assumption that in that case, the variables were set for a different process further up the process tree.
|
|
<A NAME="lbAG"> </A>
|
|
<H2>ENVIRONMENT</H2>
|
|
|
|
<P>
|
|
|
|
<I>$WATCHDOG_PID</I>
|
|
<DL COMPACT><DT id="2"><DD>
|
|
Set by the system manager for supervised process for which watchdog support is enabled, and contains the PID of that process. See above for details.
|
|
</DL>
|
|
|
|
<P>
|
|
|
|
<I>$WATCHDOG_USEC</I>
|
|
<DL COMPACT><DT id="3"><DD>
|
|
Set by the system manager for supervised process for which watchdog support is enabled, and contains the watchdog timeout in µs. See above for details.
|
|
</DL>
|
|
|
|
<A NAME="lbAH"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<P>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?1+systemd">systemd</A></B>(1),
|
|
<B><A HREF="/cgi-bin/man/man2html?3+sd-daemon">sd-daemon</A></B>(3),
|
|
<B><A HREF="/cgi-bin/man/man2html?7+daemon">daemon</A></B>(7),
|
|
<B><A HREF="/cgi-bin/man/man2html?5+systemd.service">systemd.service</A></B>(5),
|
|
<B><A HREF="/cgi-bin/man/man2html?3+sd_notify">sd_notify</A></B>(3),
|
|
<B><A HREF="/cgi-bin/man/man2html?3+sd_event_set_watchdog">sd_event_set_watchdog</A></B>(3)
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="4"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="5"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="6"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="7"><A HREF="#lbAE">RETURN VALUE</A><DD>
|
|
<DT id="8"><A HREF="#lbAF">NOTES</A><DD>
|
|
<DT id="9"><A HREF="#lbAG">ENVIRONMENT</A><DD>
|
|
<DT id="10"><A HREF="#lbAH">SEE ALSO</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:56 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|