1SD_WATCHDOG_ENABLED(3)        sd_watchdog_enabled       SD_WATCHDOG_ENABLED(3)
2
3
4

NAME

6       sd_watchdog_enabled - Check whether the service manager expects
7       watchdog keep-alive notifications from a service
8

SYNOPSIS

10       #include <systemd/sd-daemon.h>
11
12       int sd_watchdog_enabled(int unset_environment, uint64_t *usec);
13

DESCRIPTION

15       sd_watchdog_enabled() may be called by a service to detect whether the
16       service manager expects regular keep-alive watchdog notification events
17       from it, and the timeout after which the manager will act on the
18       service if it did not get such a notification.
19
20       If the $WATCHDOG_USEC environment variable is set, and the
21       $WATCHDOG_PID variable is unset or set to the PID of the current
22       process, the service manager expects notifications from this process.
23       The manager will usually terminate a service when it does not get a
24       notification message within the specified time after startup and after
25       each previous message. It is recommended that a daemon sends a
26       keep-alive notification message to the service manager every half of
27       the time returned here. Notification messages may be sent with
28       sd_notify(3) with a message string of "WATCHDOG=1".
29
30       If the unset_environment parameter is non-zero, sd_watchdog_enabled()
31       will unset the $WATCHDOG_USEC and $WATCHDOG_PID environment variables
32       before returning (regardless of whether the function call itself
33       succeeded or not). Those variables are no longer inherited by child
34       processes. Further calls to sd_watchdog_enabled() will also return with
35       zero.
36
37       If the usec parameter is non-NULL, sd_watchdog_enabled() will write the
38       timeout in µs for the watchdog logic to it.
39
40       To enable service supervision with the watchdog logic, use WatchdogSec=
41       in service files. See systemd.service(5) for details.
42

RETURN VALUE

44       On failure, this call returns a negative errno-style error code. If the
45       service manager expects watchdog keep-alive notification messages to be
46       sent, > 0 is returned, otherwise 0 is returned. Only if the return
47       value is > 0, the usec parameter is valid after the call.
48

NOTES

50       These APIs are implemented as a shared library, which can be compiled
51       and linked to with the libsystemd pkg-config(1) file.
52
53       Internally, this functions parses the $WATCHDOG_PID and $WATCHDOG_USEC
54       environment variable. The call will ignore these variables if
55       $WATCHDOG_PID does not contain the PID of the current process, under
56       the assumption that in that case, the variables were set for a
57       different process further up the process tree.
58

ENVIRONMENT

60       $WATCHDOG_PID
61           Set by the system manager for supervised process for which watchdog
62           support is enabled, and contains the PID of that process. See above
63           for details.
64
65       $WATCHDOG_USEC
66           Set by the system manager for supervised process for which watchdog
67           support is enabled, and contains the watchdog timeout in µs See
68           above for details.
69

HISTORY

71       The watchdog functionality and the $WATCHDOG_USEC variable were added
72       in systemd-41.
73
74       sd_watchdog_enabled() function was added in systemd-209. Since that
75       version the $WATCHDOG_PID variable is also set.
76

SEE ALSO

78       systemd(1), sd-daemon(3), daemon(7), systemd.service(5), sd_notify(3)
79
80
81
82systemd 219                                             SD_WATCHDOG_ENABLED(3)
Impressum