1SD_EVENT_SOURCE_SET_ENABLEDs(d3_)event_source_set_enaSbDl_eEdVENT_SOURCE_SET_ENABLED(3)
2
3
4

NAME

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

SYNOPSIS

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

DESCRIPTION

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 the event
28       source was dispatched once.
29
30       Event sources that are disabled will not result in event loop wakeups
31       and will not be dispatched, until they are enabled again.
32
33       sd_event_source_get_enabled() may be used to query whether the event
34       source object source is currently enabled or not. It returns the
35       enablement state in enabled.
36
37       Event source objects are enabled when they are first created with calls
38       such as sd_event_add_io(3), sd_event_add_time(3). However, depending on
39       the event source type they are enabled continuously (SD_EVENT_ON) or
40       only for a single invocation of the event source handler
41       (SD_EVENT_ONESHOT). For details see the respective manual pages.
42
43       As event source objects stay active and may be dispatched as long as
44       there is at least one reference to them, in many cases it is a good
45       idea to combine a call to sd_event_source_unref(3) with a prior call to
46       sd_event_source_set_enabled() with SD_EVENT_OFF, to ensure the event
47       source is not dispatched again until all other remaining references are
48       dropped.
49

RETURN VALUE

51       On success, sd_event_source_set_enabled() and
52       sd_event_source_get_enabled() return a non-negative integer. On
53       failure, they return a negative errno-style error code.
54

ERRORS

56       Returned errors may indicate the following problems:
57
58       -EINVAL
59           source is not a valid pointer to an sd_event_source object.
60
61       -ENOMEM
62           Not enough memory.
63
64       -ECHILD
65           The event loop has been created in a different process.
66

NOTES

68       These APIs are implemented as a shared library, which can be compiled
69       and linked to with the libsystemd pkg-config(1) file.
70

SEE ALSO

72       sd-event(3), sd_event_add_io(3), sd_event_add_time(3),
73       sd_event_add_child(3), sd_event_add_signal(3), sd_event_add_defer(3),
74       sd_event_source_unref(3)
75
76
77
78systemd 239                                     SD_EVENT_SOURCE_SET_ENABLED(3)
Impressum