1SD_EVENT_SOURCE_SET_PREPAREs(d3_)event_source_set_preSpDa_rEeVENT_SOURCE_SET_PREPARE(3)
2
3
4

NAME

6       sd_event_source_set_prepare - Set a preparation callback for event
7       sources
8

SYNOPSIS

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

DESCRIPTION

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

RETURN VALUE

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
41   Errors
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, library or
55           module instance.
56
57       -EDOM
58           The specified event source has been created with
59           sd_event_add_exit(3).
60

NOTES

62       Functions described here are available as a shared library, which can
63       be compiled against and linked to with the libsystemd pkg-config(1)
64       file.
65
66       The code described here uses getenv(3), which is declared to be not
67       multi-thread-safe. This means that the code calling the functions
68       described here must not call setenv(3) from a parallel thread. It is
69       recommended to only do calls to setenv() from an early phase of the
70       program when no other threads have been started.
71

SEE ALSO

73       sd-event(3), sd_event_add_io(3), sd_event_add_time(3),
74       sd_event_add_signal(3), sd_event_add_child(3), sd_event_add_inotify(3),
75       sd_event_add_defer(3), sd_event_source_set_enabled(3),
76       sd_event_source_set_priority(3), sd_event_source_set_userdata(3)
77
78
79
80systemd 254                                     SD_EVENT_SOURCE_SET_PREPARE(3)
Impressum