File: sd_event_run.3

package info (click to toggle)
manpages-de 2.12-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 71,404 kB
  • sloc: sh: 1,059; makefile: 71; python: 64; perl: 37; sed: 11
file content (138 lines) | stat: -rw-r--r-- 4,108 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
'\" t
.TH "SD_EVENT_RUN" "3" "" "systemd 241" "sd_event_run"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
sd_event_run, sd_event_loop \- Run an event loop
.SH "SYNOPSIS"
.sp
.ft B
.nf
#include <systemd/sd\-event\&.h>
.fi
.ft
.HP \w'int\ sd_event_run('u
.BI "int sd_event_run(sd_event\ *" "event" ", uint64_t\ " "usec" ");"
.HP \w'int\ sd_event_loop('u
.BI "int sd_event_loop(sd_event\ *" "event" ");"
.SH "DESCRIPTION"
.PP
\fBsd_event_run()\fR
may be used to run a single iteration of the event loop specified in the
\fIevent\fR
parameter\&. The function waits until an event to process is available, and dispatches the registered handler for it\&. The
\fIusec\fR
parameter specifies the maximum time (in microseconds) to wait for an event\&. Use
\fB(uint64_t) \-1\fR
to specify an infinite timeout\&.
.PP
\fBsd_event_loop()\fR
invokes
\fBsd_event_run()\fR
in a loop, thus implementing the actual event loop\&. The call returns as soon as exiting was requested using
\fBsd_event_exit\fR(3)\&.
.PP
The event loop object
\fIevent\fR
is created with
\fBsd_event_new\fR(3)\&. Events sources to wait for and their handlers may be registered with
\fBsd_event_add_io\fR(3),
\fBsd_event_add_time\fR(3),
\fBsd_event_add_signal\fR(3),
\fBsd_event_add_child\fR(3),
\fBsd_event_add_defer\fR(3),
\fBsd_event_add_post\fR(3)
and
\fBsd_event_add_exit\fR(3)\&.
.PP
For low\-level control of event loop execution, use
\fBsd_event_prepare\fR(3),
\fBsd_event_wait\fR(3)
and
\fBsd_event_dispatch\fR(3)
which are wrapped by
\fBsd_event_run()\fR\&. Along with
\fBsd_event_get_fd\fR(3), these functions allow integration of an
\fBsd-event\fR(3)
event loop into foreign event loop implementations\&.
.SH "RETURN VALUE"
.PP
On failure, these functions return a negative errno\-style error code\&.
\fBsd_event_run()\fR
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\&.
\fBsd_event_loop()\fR
returns the exit code specified when invoking
\fBsd_event_exit()\fR\&.
.SH "ERRORS"
.PP
Returned errors may indicate the following problems:
.PP
\fB\-EINVAL\fR
.RS 4
The
\fIevent\fR
parameter is invalid or
\fBNULL\fR\&.
.RE
.PP
\fB\-EBUSY\fR
.RS 4
The event loop object is not in the right state (see
\fBsd_event_prepare\fR(3)
for an explanation of possible states)\&.
.RE
.PP
\fB\-ESTALE\fR
.RS 4
The event loop is already terminated\&.
.RE
.PP
\fB\-ECHILD\fR
.RS 4
The event loop has been created in a different process\&.
.RE
.PP
Other errors are possible, too\&.
.SH "NOTES"
.PP
These APIs are implemented as a shared library, which can be compiled and linked to with the
\fBlibsystemd\fR\ \&\fBpkg-config\fR(1)
file\&.
.SH "SEE ALSO"
.PP
\fBsystemd\fR(1),
\fBsd-event\fR(3),
\fBsd_event_new\fR(3),
\fBsd_event_add_io\fR(3),
\fBsd_event_add_time\fR(3),
\fBsd_event_add_signal\fR(3),
\fBsd_event_add_child\fR(3),
\fBsd_event_add_inotify\fR(3),
\fBsd_event_add_defer\fR(3),
\fBsd_event_exit\fR(3),
\fBsd_event_get_fd\fR(3),
\fBsd_event_wait\fR(3),
\m[blue]\fBGLib Main Event Loop\fR\m[]\&\s-2\u[1]\d\s+2
.SH "NOTES"
.IP " 1." 4
GLib Main Event Loop
.RS 4
\%https://developer.gnome.org/glib/unstable/glib-The-Main-Event-Loop.html
.RE