Debian Codegraph @

upstream/debian-unstable/man3/sd_event_set_watchdog.3

raw
1 '\" t
2 .TH "SD_EVENT_SET_WATCHDOG" "3" "" "systemd 261~rc3" "sd_event_set_watchdog"
3 .\" -----------------------------------------------------------------
4 .\" * Define some portability stuff
5 .\" -----------------------------------------------------------------
6 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 .\" http://bugs.debian.org/507673
8 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
9 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 .ie \n(.g .ds Aq \(aq
11 .el .ds Aq '
12 .\" -----------------------------------------------------------------
13 .\" * set default formatting
14 .\" -----------------------------------------------------------------
15 .\" disable hyphenation
16 .nh
17 .\" disable justification (adjust text to left margin only)
18 .ad l
19 .\" -----------------------------------------------------------------
20 .\" * MAIN CONTENT STARTS HERE *
21 .\" -----------------------------------------------------------------
22 .SH "NAME"
23 sd_event_set_watchdog, sd_event_get_watchdog \- Enable event loop watchdog support
24 .SH "SYNOPSIS"
25 .sp
26 .ft B
27 .nf
28 #include <systemd/sd\-event\&.h>
29 .fi
30 .ft
31 .HP \w'int\ sd_event_set_watchdog('u
32 .BI "int sd_event_set_watchdog(sd_event\ *" "event" ", int\ b);"
33 .HP \w'int\ sd_event_get_watchdog('u
34 .BI "int sd_event_get_watchdog(sd_event\ *" "event" ");"
35 .SH "DESCRIPTION"
36 .PP
37 \fBsd_event_set_watchdog()\fR
38 may be used to enable or disable automatic watchdog notification support in the event loop object specified in the
39 \fIevent\fR
40 parameter\&. Specifically, depending on the
41 \fIb\fR
42 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
43 \fBsd_watchdog_enabled\fR(3), and watchdog messages are sent with
44 \fBsd_notify\fR(3)\&. See the
45 \fIWatchdogSec=\fR
46 setting in
47 \fBsystemd.service\fR(5)
48 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
49 \fI$WATCHDOG_USEC\fR
50 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
51 \fIb\fR
52 parameter executes no operation\&. Passing a false
53 \fIb\fR
54 parameter will disable the automatic sending of watchdog notification messages if it was enabled before\&. Newly allocated event loop objects have this feature disabled\&.
55 .PP
56 The first watchdog notification message is sent immediately when
57 \fBsd_event_set_watchdog()\fR
58 is invoked with a true
59 \fIb\fR
60 parameter\&.
61 .PP
62 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\&.
63 .PP
64 \fBsd_event_get_watchdog()\fR
65 may be used to determine whether watchdog support was previously requested by a call to
66 \fBsd_event_set_watchdog()\fR
67 with a true
68 \fIb\fR
69 parameter and successfully enabled\&.
70 .SH "RETURN VALUE"
71 .PP
72 On success,
73 \fBsd_event_set_watchdog()\fR
74 and
75 \fBsd_event_get_watchdog()\fR
76 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
77 \fIb\fR
78 parameter\&. On failure, they return a negative errno\-style error code\&.
79 .SS "Errors"
80 .PP
81 Returned errors may indicate the following problems:
82 .PP
83 \fB\-ECHILD\fR
84 .RS 4
85 The event loop has been created in a different process, library or module instance\&.
86 .RE
87 .PP
88 \fB\-EINVAL\fR
89 .RS 4
90 The passed event loop object was invalid\&.
91 .RE
92 .SH "NOTES"
93 .PP
94 Functions described here are available as a shared library, which can be compiled against and linked to with the
95 \fBlibsystemd\fR\ \&\fBpkg-config\fR(1)
96 file\&.
97 .PP
98 The code described here uses
99 \fBgetenv\fR(3), which is declared to be not multi\-thread\-safe\&. This means that the code calling the functions described here must not call
100 \fBsetenv\fR(3)
101 from a parallel thread\&. It is recommended to only do calls to
102 \fBsetenv()\fR
103 from an early phase of the program when no other threads have been started\&.
104 .SH "HISTORY"
105 .PP
106 \fBsd_event_set_watchdog()\fR
107 and
108 \fBsd_event_get_watchdog()\fR
109 were added in version 229\&.
110 .SH "SEE ALSO"
111 .PP
112 \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)