Debian Codegraph @

upstream/debian-unstable/man3/sd_event_run.3

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