'\" t .TH "SD_WATCHDOG_ENABLED" "3" "" "systemd 241" "sd_watchdog_enabled" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" sd_watchdog_enabled \- Check whether the service manager expects watchdog keep\-alive notifications from a service .SH "SYNOPSIS" .sp .ft B .nf #include .fi .ft .HP \w'int\ sd_watchdog_enabled('u .BI "int sd_watchdog_enabled(int\ " "unset_environment" ", uint64_t\ *" "usec" ");" .SH "DESCRIPTION" .PP \fBsd_watchdog_enabled()\fR 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\&. .PP If the \fI$WATCHDOG_USEC\fR environment variable is set, and the \fI$WATCHDOG_PID\fR 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 \fBsd_notify\fR(3) with a message string of "WATCHDOG=1"\&. .PP If the \fIunset_environment\fR parameter is non\-zero, \fBsd_watchdog_enabled()\fR will unset the \fI$WATCHDOG_USEC\fR and \fI$WATCHDOG_PID\fR 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 \fBsd_watchdog_enabled()\fR will also return with zero\&. .PP If the \fIusec\fR parameter is non\-NULL, \fBsd_watchdog_enabled()\fR will write the timeout in \(mcs for the watchdog logic to it\&. .PP To enable service supervision with the watchdog logic, use \fIWatchdogSec=\fR in service files\&. See \fBsystemd.service\fR(5) for details\&. .PP Use \fBsd_event_set_watchdog\fR(3) to enable automatic watchdog support in \fBsd-event\fR(3)\-based event loops\&. .SH "RETURN VALUE" .PP 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 \fIusec\fR parameter is valid after the call\&. .SH "NOTES" .PP These APIs are implemented as a shared library, which can be compiled and linked to with the \fBlibsystemd\fR\ \&\fBpkg-config\fR(1) file\&. .PP Internally, this function parses the \fI$WATCHDOG_PID\fR and \fI$WATCHDOG_USEC\fR environment variable\&. The call will ignore these variables if \fI$WATCHDOG_PID\fR 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\&. .SH "ENVIRONMENT" .PP \fI$WATCHDOG_PID\fR .RS 4 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\&. .RE .PP \fI$WATCHDOG_USEC\fR .RS 4 Set by the system manager for supervised process for which watchdog support is enabled, and contains the watchdog timeout in \(mcs\&. See above for details\&. .RE .SH "SEE ALSO" .PP \fBsystemd\fR(1), \fBsd-daemon\fR(3), \fBdaemon\fR(7), \fBsystemd.service\fR(5), \fBsd_notify\fR(3), \fBsd_event_set_watchdog\fR(3)