1SD_EVENT_SOURCE_SET_ENABLEDs(d3_)event_source_set_enaSbDl_eEdVENT_SOURCE_SET_ENABLED(3)
2
3
4
6 sd_event_source_set_enabled, sd_event_source_get_enabled, SD_EVENT_ON,
7 SD_EVENT_OFF, SD_EVENT_ONESHOT - Enable or disable event sources
8
10 #include <systemd/sd-event.h>
11
12 enum {
13 SD_EVENT_OFF = 0,
14 SD_EVENT_ON = 1,
15 SD_EVENT_ONESHOT = -1,
16 };
17
18 int sd_event_source_set_enabled(sd_event_source *source, int enabled);
19
20 int sd_event_source_get_enabled(sd_event_source *source, int *enabled);
21
23 sd_event_source_set_enabled() may be used to enable or disable the
24 event source object specified as source. The enabled parameter takes
25 one of SD_EVENT_ON (to enable), SD_EVENT_OFF (to disable) or
26 SD_EVENT_ONESHOT. If invoked with SD_EVENT_ONESHOT the event source
27 will be enabled but automatically reset to SD_EVENT_OFF after one
28 dispatch. For SD_EVENT_OFF, the event source source may be NULL, in
29 which case the function does nothing. Otherwise, source must be a valid
30 pointer to an sd_event_source object.
31
32 Event sources that are disabled will not result in event loop wakeups
33 and will not be dispatched, until they are enabled again.
34
35 sd_event_source_get_enabled() may be used to query whether the event
36 source object source is currently enabled or not. If both the source
37 and the output parameter enabled are NULL, this function returns false.
38 Otherwise, source must be a valid pointer to an sd_event_source object.
39 If the output parameter enabled is not NULL, it is set to the
40 enablement state (one of SD_EVENT_ON, SD_EVENT_OFF, SD_EVENT_ONESHOT).
41 The function also returns true if the event source is not disabled.
42
43 Event source objects are enabled when they are first created with calls
44 such as sd_event_add_io(3), sd_event_add_time(3). However, depending on
45 the event source type they are enabled continuously (SD_EVENT_ON) or
46 only for a single invocation of the event source handler
47 (SD_EVENT_ONESHOT). For details see the respective manual pages.
48
49 As event source objects stay active and may be dispatched as long as
50 there is at least one reference to them, in many cases it is a good
51 idea to combine a call to sd_event_source_unref(3) with a prior call to
52 sd_event_source_set_enabled() with SD_EVENT_OFF, to ensure the event
53 source is not dispatched again until all other remaining references are
54 dropped.
55
57 On success, sd_event_source_set_enabled() returns a non-negative
58 integer. sd_event_source_get_enabled() returns zero if the source is
59 disabled (SD_EVENT_OFF) and a positive integer otherwise. On failure,
60 they return a negative errno-style error code.
61
62 Errors
63 Returned errors may indicate the following problems:
64
65 -EINVAL
66 source is not a valid pointer to an sd_event_source object.
67
68 -ENOMEM
69 Not enough memory.
70
71 -ECHILD
72 The event loop has been created in a different process.
73
75 These APIs are implemented as a shared library, which can be compiled
76 and linked to with the libsystemd pkg-config(1) file.
77
79 sd-event(3), sd_event_add_io(3), sd_event_add_time(3),
80 sd_event_add_signal(3), sd_event_add_child(3), sd_event_add_inotify(3),
81 sd_event_add_defer(3), sd_event_source_unref(3),
82 sd_event_source_set_ratelimit(3)
83
84
85
86systemd 253 SD_EVENT_SOURCE_SET_ENABLED(3)