跳转到主要内容

sd_event_get_fd

systemd

sd_event_get_fd

3

sd_event_get_fd

Obtain a file descriptor to poll for event loop events

#include <systemd/sd-event.h>

int

sd_event_get_fd

sd_event *

event

Description

sd_event_get_fd() returns the file descriptor that an event loop object returned by the sd_event_new(3) function uses to wait for events. This file descriptor may itself be polled for POLLIN/EPOLLIN events. This makes it possible to embed an sd-event(3) event loop into another, possibly foreign, event loop.

The returned file descriptor refers to an epoll(7) object. It is recommended not to alter it by invoking epoll_ctl(2) on it, in order to avoid interference with the event loop's inner logic and assumptions.

Return Value

On success, sd_event_get_fd() returns a non-negative file descriptor. On failure, it returns a negative errno-style error code.

Errors

Returned errors may indicate the following problems:

-EINVAL
event is not a valid pointer to an sd_event structure.

-ECHILD
The event loop has been created in a different process, library or module instance.

Examples

Integration in the GLib event loop

History

sd_event_get_fd() was added in version 217.

See Also

sd-event(3), sd_event_new(3), sd_event_wait(3), epoll_ctl(2), epoll(7)