1SD_EVENT_SOURCE_SET_PREPAREs(d3_)event_source_set_preSpDa_rEeVENT_SOURCE_SET_PREPARE(3)
2
3
4
6 sd_event_source_set_prepare - Set a preparation callback for event
7 sources
8
10 #include <systemd/sd-event.h>
11
12 int sd_event_source_set_prepare(sd_event_source *source,
13 sd_event_handler_t callback);
14
15 typedef int (*sd_event_handler_t)(sd_event_source *s, void *userdata);
16
18 sd_event_source_set_prepare() may be used to set a preparation callback
19 for the event source object specified as source. The callback function
20 specified as callback will be invoked immediately before the event loop
21 goes to sleep to wait for incoming events. It is invoked with the user
22 data pointer passed when the event source was created. The event source
23 will be disabled if the callback function returns a negative error
24 code. The callback function may be used to reconfigure the precise
25 events to wait for. If the callback parameter is passed as NULL the
26 callback function is reset.
27
28 Event source objects have no preparation callback associated when they
29 are first created with calls such as sd_event_add_io(3),
30 sd_event_add_time(3). Preparation callback functions are supported for
31 all event source types with the exception of those created with
32 sd_event_add_exit(3). Preparation callback functions are dispatched in
33 the order indicated by the event source's priority field, as set with
34 sd_event_source_set_priority(3). Preparation callbacks of disabled
35 event sources (see sd_event_source_set_enabled(3)) are not invoked.
36
38 On success, sd_event_source_set_prepare() returns a non-negative
39 integer. On failure, it returns a negative errno-style error code.
40
42 Returned errors may indicate the following problems:
43
44 -EINVAL
45 source is not a valid pointer to an sd_event_source object.
46
47 -ESTALE
48 The event loop is already terminated.
49
50 -ENOMEM
51 Not enough memory.
52
53 -ECHILD
54 The event loop has been created in a different process.
55
56 -EDOM
57 The specified event source has been created with
58 sd_event_add_exit(3).
59
61 These APIs are implemented as a shared library, which can be compiled
62 and linked to with the libsystemd pkg-config(1) file.
63
65 sd-event(3), sd_event_add_io(3), sd_event_add_time(3),
66 sd_event_add_child(3), sd_event_add_signal(3), sd_event_add_defer(3),
67 sd_event_source_set_enabled(3), sd_event_source_set_priority(3),
68 sd_event_source_set_userdata(3)
69
70
71
72systemd 239 SD_EVENT_SOURCE_SET_PREPARE(3)