1SD_EVENT_RUN(3)                  sd_event_run                  SD_EVENT_RUN(3)
2
3
4

NAME

6       sd_event_run, sd_event_loop - Run an event loop
7

SYNOPSIS

9       #include <systemd/sd-event.h>
10
11       int sd_event_run(sd_event *event, uint64_t usec);
12
13       int sd_event_loop(sd_event *event);
14

DESCRIPTION

16       sd_event_run() may be used to run a single iteration of the event loop
17       specified in the event parameter. The function waits until an event to
18       process is available, and dispatches the registered handler for it. The
19       usec parameter specifies the maximum time (in microseconds) to wait for
20       an event. Use (uint64_t) -1 to specify an infinite timeout.
21
22       sd_event_loop() invokes sd_event_run() in a loop, thus implementing the
23       actual event loop. The call returns as soon as exiting was requested
24       using sd_event_exit(3).
25
26       The event loop object event is created with sd_event_new(3). Events
27       sources to wait for and their handlers may be registered with
28       sd_event_add_io(3), sd_event_add_time(3), sd_event_add_signal(3),
29       sd_event_add_child(3), sd_event_add_defer(3), sd_event_add_post(3) and
30       sd_event_add_exit(3).
31
32       For low-level control of event loop execution, use sd_event_prepare(3),
33       sd_event_wait(3) and sd_event_dispatch(3) which are wrapped by
34       sd_event_run(). Along with sd_event_get_fd(3), these functions allow
35       integration of an sd-event(3) event loop into foreign event loop
36       implementations.
37

RETURN VALUE

39       On failure, these functions return a negative errno-style error code.
40       sd_event_run() returns a positive, non-zero integer if an event source
41       was dispatched, and zero when the specified timeout hit before an event
42       source has seen any event, and hence no event source was dispatched.
43       sd_event_loop() returns the exit code specified when invoking
44       sd_event_exit().
45
46   Errors
47       Returned errors may indicate the following problems:
48
49       -EINVAL
50           The event parameter is invalid or NULL.
51
52       -EBUSY
53           The event loop object is not in the right state (see
54           sd_event_prepare(3) for an explanation of possible states).
55
56       -ESTALE
57           The event loop is already terminated.
58
59       -ECHILD
60           The event loop has been created in a different process, library or
61           module instance.
62
63       Other errors are possible, too.
64

NOTES

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

SEE ALSO

77       systemd(1), sd-event(3), sd_event_new(3), sd_event_add_io(3),
78       sd_event_add_time(3), sd_event_add_signal(3), sd_event_add_child(3),
79       sd_event_add_inotify(3), sd_event_add_defer(3), sd_event_exit(3),
80       sd_event_get_fd(3), sd_event_wait(3), GLib Main Event Loop[1]
81

NOTES

83        1. GLib Main Event Loop
84           https://developer.gnome.org/glib/unstable/glib-The-Main-Event-Loop.html
85
86
87
88systemd 254                                                    SD_EVENT_RUN(3)
Impressum