sd_event_add_defer, sd_event_add_post, sd_event_add_exit — Add static event sources to an event loop
#include <systemd/sd-bus.h>
int sd_event_add_defer( | sd_event *event, |
sd_event_source **source, | |
sd_event_handler_t handler, | |
void *userdata) ; |
int sd_event_add_post( | sd_event *event, |
sd_event_source **source, | |
sd_event_handler_t handler, | |
void *userdata) ; |
int sd_event_add_exit( | sd_event *event, |
sd_event_source **source, | |
sd_event_handler_t handler, | |
void *userdata) ; |
typedef int (*sd_event_handler_t)( | sd_event_source *s, |
void *userdata) ; |
Those three functions add new event sources to an event loop
object. The event loop is specified in
event
, the event source is returned in the
source
parameter. The event sources are
enabled statically and will "fire" when the event loop is run and
the conditions described below are met. The handler function will
be passed the userdata
pointer, which may
be chosen freely by the caller.
sd_event_add_defer()
adds a new event
source that will "fire" the next time the event loop is run. By
default, the handler will be called once
(SD_EVENT_ONESHOT
).
sd_event_add_post()
adds a new event
source that will "fire" if any event handlers are invoked whenever
the event loop is run. By default, the source is enabled
permanently (SD_EVENT_ON
).
sd_event_add_exit()
adds a new event
source that will "fire" when the event loop is terminated
with sd_event_exit()
.
The
sd_event_source_set_enabled(3)
function may be used to enable the event source permanently
(SD_EVENT_ON
) or to make it fire just once
(SD_EVENT_ONESHOT
). If the handler function
returns a negative error code, it will be disabled after the
invocation, even if SD_EVENT_ON
mode is
set.
On success, this functions return 0 or a positive integer. On failure, they return a negative errno-style error code.
Functions described here are available as a shared library,
which can be compiled and linked to with the
libsystemd
pkg-config(1)
file.