sd_event_loop(3) — Linux manual page


SD_EVENT_RUN(3)                 sd_event_run                 SD_EVENT_RUN(3)

NAME         top

       sd_event_run, sd_event_loop - Run an event loop

SYNOPSIS         top

       #include <systemd/sd-event.h>

       int sd_event_run(sd_event *event, uint64_t usec);

       int sd_event_loop(sd_event *event);

DESCRIPTION         top

       sd_event_run() may be used to run a single iteration of the event
       loop specified in the event parameter. The function waits until an
       event to process is available, and dispatches the registered handler
       for it. The usec parameter specifies the maximum time (in
       microseconds) to wait for an event. Use (uint64_t) -1 to specify an
       infinite timeout.

       sd_event_loop() invokes sd_event_run() in a loop, thus implementing
       the actual event loop. The call returns as soon as exiting was
       requested using sd_event_exit(3).

       The event loop object event is created with sd_event_new(3). Events
       sources to wait for and their handlers may be registered with
       sd_event_add_io(3), sd_event_add_time(3), sd_event_add_signal(3),
       sd_event_add_child(3), sd_event_add_defer(3), sd_event_add_post(3)
       and sd_event_add_exit(3).

       For low-level control of event loop execution, use
       sd_event_prepare(3), sd_event_wait(3) and sd_event_dispatch(3) which
       are wrapped by sd_event_run(). Along with sd_event_get_fd(3), these
       functions allow integration of an sd-event(3) event loop into foreign
       event loop implementations.

RETURN VALUE         top

       On failure, these functions return a negative errno-style error code.
       sd_event_run() returns a positive, non-zero integer if an event
       source was dispatched, and zero when the specified timeout hit before
       an event source has seen any event, and hence no event source was
       dispatched.  sd_event_loop() returns the exit code specified when
       invoking sd_event_exit().

       Returned errors may indicate the following problems:

           The event parameter is invalid or NULL.

           The event loop object is not in the right state (see
           sd_event_prepare(3) for an explanation of possible states).

           The event loop is already terminated.

           The event loop has been created in a different process.

       Other errors are possible, too.

NOTES         top

       These APIs are implemented as a shared library, which can be compiled
       and linked to with the libsystemd pkg-config(1) file.

SEE ALSO         top

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

NOTES         top

        1. GLib Main Event Loop

COLOPHON         top

       This page is part of the systemd (systemd system and service manager)
       project.  Information about the project can be found at 
       ⟨⟩.  If you have a bug
       report for this manual page, see
       ⟨⟩.  This
       page was obtained from the project's upstream Git repository
       ⟨⟩ on 2020-08-13.  (At that
       time, the date of the most recent commit that was found in the repos‐
       itory was 2020-08-11.)  If you discover any rendering problems in
       this HTML version of the page, or you believe there is a better or
       more up-to-date source for the page, or you have corrections or
       improvements to the information in this COLOPHON (which is not part
       of the original manual page), send a mail to

systemd 246                                                  SD_EVENT_RUN(3)

Pages that refer to this page: sd_event(3)sd_event_armed(3)SD_EVENT_ARMED(3)sd_event_default(3)sd_event_dispatch(3)sd_event_exit(3)sd_event_exiting(3)SD_EVENT_EXITING(3)sd_event_finished(3)SD_EVENT_FINISHED(3)sd_event_get_exit_code(3)sd_event_get_iteration(3)sd_event_get_state(3)sd_event_get_tid(3)sd_event_initial(3)SD_EVENT_INITIAL(3)sd_event_new(3)sd_event_pending(3)SD_EVENT_PENDING(3)sd_event_prepare(3)sd_event_preparing(3)SD_EVENT_PREPARING(3)sd_event_ref(3)sd_event_running(3)SD_EVENT_RUNNING(3)sd_event_unref(3)sd_event_unrefp(3)sd_event_wait(3)30-systemd-environment-d-generator(7)systemd.index(7)