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
43       Use sd_event_set_watchdog(3) to enable automatic watchdog support in
44       sd-event(3)-based event loops.
45

RETURN VALUE

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

NOTES

53       Functions described here are available as a shared library, which can
54       be compiled against and linked to with the libsystemd pkg-config(1)
55       file.
56
57       The code described here uses getenv(3), which is declared to be not
58       multi-thread-safe. This means that the code calling the functions
59       described here must not call setenv(3) from a parallel thread. It is
60       recommended to only do calls to setenv() from an early phase of the
61       program when no other threads have been started.
62
63       Internally, this function parses the $WATCHDOG_PID and $WATCHDOG_USEC
64       environment variable. The call will ignore these variables if
65       $WATCHDOG_PID does not contain the PID of the current process, under
66       the assumption that in that case, the variables were set for a
67       different process further up the process tree.
68

ENVIRONMENT

70       $WATCHDOG_PID
71           Set by the system manager for supervised process for which watchdog
72           support is enabled, and contains the PID of that process. See above
73           for details.
74
75       $WATCHDOG_USEC
76           Set by the system manager for supervised process for which watchdog
77           support is enabled, and contains the watchdog timeout in μs. See
78           above for details.
79

SEE ALSO

81       systemd(1), sd-daemon(3), daemon(7), systemd.service(5), sd_notify(3),
82       sd_event_set_watchdog(3)
83
84
85
86systemd 254                                             SD_WATCHDOG_ENABLED(3)
Impressum