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 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

RETURN VALUE

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, library or
73           module instance.
74

NOTES

76       Functions described here are available as a shared library, which can
77       be compiled against and linked to with the libsystemd pkg-config(1)
78       file.
79
80       The code described here uses getenv(3), which is declared to be not
81       multi-thread-safe. This means that the code calling the functions
82       described here must not call setenv(3) from a parallel thread. It is
83       recommended to only do calls to setenv() from an early phase of the
84       program when no other threads have been started.
85

SEE ALSO

87       sd-event(3), sd_event_add_io(3), sd_event_add_time(3),
88       sd_event_add_signal(3), sd_event_add_child(3), sd_event_add_inotify(3),
89       sd_event_add_defer(3), sd_event_source_unref(3),
90       sd_event_source_set_ratelimit(3)
91
92
93
94systemd 254                                     SD_EVENT_SOURCE_SET_ENABLED(3)
Impressum