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 (one of SD_EVENT_ON, SD_EVENT_OFF, SD_EVENT_ONESHOT)
36       in enabled, if it is not NULL. It also returns true if the event source
37       is not disabled.
38
39       Event source objects are enabled when they are first created with calls
40       such as sd_event_add_io(3), sd_event_add_time(3). However, depending on
41       the event source type they are enabled continuously (SD_EVENT_ON) or
42       only for a single invocation of the event source handler
43       (SD_EVENT_ONESHOT). For details see the respective manual pages.
44
45       As event source objects stay active and may be dispatched as long as
46       there is at least one reference to them, in many cases it is a good
47       idea to combine a call to sd_event_source_unref(3) with a prior call to
48       sd_event_source_set_enabled() with SD_EVENT_OFF, to ensure the event
49       source is not dispatched again until all other remaining references are
50       dropped.
51

RETURN VALUE

53       On success, sd_event_source_set_enabled() returns a non-negative
54       integer.  sd_event_source_get_enabled() returns zero if the source is
55       disabled (SD_EVENT_OFF) and a positive integer otherwise. On failure,
56       they return a negative errno-style error code.
57

ERRORS

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

NOTES

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

SEE ALSO

75       sd-event(3), sd_event_add_io(3), sd_event_add_time(3),
76       sd_event_add_signal(3), sd_event_add_child(3), sd_event_add_inotify(3),
77       sd_event_add_defer(3), sd_event_source_unref(3)
78
79
80
81systemd 241                                     SD_EVENT_SOURCE_SET_ENABLED(3)
Impressum