'\" t .TH "SD_EVENT_SET_WATCHDOG" "3" "" "systemd 241" "sd_event_set_watchdog" .\" ----------------------------------------------------------------- .\" * 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_event_set_watchdog, sd_event_get_watchdog \- Enable event loop watchdog support .SH "SYNOPSIS" .sp .ft B .nf #include .fi .ft .HP \w'int\ sd_event_set_watchdog('u .BI "int sd_event_set_watchdog(sd_event\ *" "event" ", int\ b);" .HP \w'int\ sd_event_get_watchdog('u .BI "int sd_event_get_watchdog(sd_event\ *" "event" ");" .SH "DESCRIPTION" .PP \fBsd_event_set_watchdog()\fR may be used to enable or disable automatic watchdog notification support in the event loop object specified in the \fIevent\fR parameter\&. Specifically, depending on the \fIb\fR boolean argument this will make sure the event loop wakes up in regular intervals and sends watchdog notification messages to the service manager, if this was requested by the service manager\&. Watchdog support is determined with \fBsd_watchdog_enabled\fR(3), and watchdog messages are sent with \fBsd_notify\fR(3)\&. See the \fIWatchdogSec=\fR setting in \fBsystemd.service\fR(5) for details on how to enable watchdog support for a service and the protocol used\&. The wake\-up interval is chosen as half the watchdog timeout declared by the service manager via the \fI$WATCHDOG_USEC\fR environment variable\&. If the service manager did not request watchdog notifications, or if the process was not invoked by the service manager this call with a true \fIb\fR parameter executes no operation\&. Passing a false \fIb\fR parameter will disable the automatic sending of watchdog notification messages if it was enabled before\&. Newly allocated event loop objects have this feature disabled\&. .PP The first watchdog notification message is sent immediately when \fBset_event_set_watchdog()\fR is invoked with a true \fIb\fR parameter\&. .PP The watchdog logic is designed to allow the service manager to automatically detect services that ceased processing of incoming events, and thus appear "hung"\&. Watchdog notifications are sent out only at the beginning of each event loop iteration\&. If an event source dispatch function blocks for an excessively long time and does not return execution to the event loop quickly, this might hence cause the notification message to be delayed, and possibly result in abnormal program termination, as configured in the service unit file\&. .PP \fBsd_event_get_watchdog()\fR may be used to determine whether watchdog support was previously requested by a call to \fBsd_event_set_watchdog()\fR with a true \fIb\fR parameter and successfully enabled\&. .SH "RETURN VALUE" .PP On success, \fBsd_event_set_watchdog()\fR and \fBsd_event_get_watchdog()\fR return a non\-zero positive integer if the service manager requested watchdog support and watchdog support was successfully enabled\&. They return zero if the service manager did not request watchdog support, or if watchdog support was explicitly disabled with a false \fIb\fR parameter\&. On failure, they return a negative errno\-style error code\&. .SH "ERRORS" .PP Returned errors may indicate the following problems: .PP \fB\-ECHILD\fR .RS 4 The event loop has been created in a different process\&. .RE .PP \fB\-EINVAL\fR .RS 4 The passed event loop object was invalid\&. .RE .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\&. .SH "SEE ALSO" .PP \fBsystemd\fR(1), \fBsd-event\fR(3), \fBsd_event_new\fR(3), \fBsd_event_add_io\fR(3), \fBsd_event_add_time\fR(3), \fBsd_event_add_signal\fR(3), \fBsd_event_add_child\fR(3), \fBsd_event_add_inotify\fR(3), \fBsd_event_add_defer\fR(3), \fBsd_watchdog_enabled\fR(3), \fBsd_notify\fR(3), \fBsystemd.service\fR(5)