]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/sd_event_source_set_enabled.xml
Merge pull request #11580 from yuwata/fix-11579
[thirdparty/systemd.git] / man / sd_event_source_set_enabled.xml
CommitLineData
514094f9 1<?xml version='1.0'?>
dc83f27a
LP
2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4
5<!--
572eb058 6 SPDX-License-Identifier: LGPL-2.1+
dc83f27a
LP
7-->
8
9<refentry id="sd_event_source_set_enabled" xmlns:xi="http://www.w3.org/2001/XInclude">
10
11 <refentryinfo>
12 <title>sd_event_source_set_enabled</title>
13 <productname>systemd</productname>
dc83f27a
LP
14 </refentryinfo>
15
16 <refmeta>
17 <refentrytitle>sd_event_source_set_enabled</refentrytitle>
18 <manvolnum>3</manvolnum>
19 </refmeta>
20
21 <refnamediv>
22 <refname>sd_event_source_set_enabled</refname>
23 <refname>sd_event_source_get_enabled</refname>
24 <refname>SD_EVENT_ON</refname>
25 <refname>SD_EVENT_OFF</refname>
26 <refname>SD_EVENT_ONESHOT</refname>
27
28 <refpurpose>Enable or disable event sources</refpurpose>
29 </refnamediv>
30
31 <refsynopsisdiv>
32 <funcsynopsis>
33 <funcsynopsisinfo>#include &lt;systemd/sd-event.h&gt;</funcsynopsisinfo>
34
35 <funcsynopsisinfo><token>enum</token> {
36 <constant>SD_EVENT_OFF</constant> = 0,
37 <constant>SD_EVENT_ON</constant> = 1,
38 <constant>SD_EVENT_ONESHOT</constant> = -1,
39};</funcsynopsisinfo>
40
41 <funcprototype>
42 <funcdef>int <function>sd_event_source_set_enabled</function></funcdef>
43 <paramdef>sd_event_source *<parameter>source</parameter></paramdef>
44 <paramdef>int <parameter>enabled</parameter></paramdef>
45 </funcprototype>
46
47 <funcprototype>
48 <funcdef>int <function>sd_event_source_get_enabled</function></funcdef>
49 <paramdef>sd_event_source *<parameter>source</parameter></paramdef>
50 <paramdef>int *<parameter>enabled</parameter></paramdef>
51 </funcprototype>
52
53 </funcsynopsis>
54 </refsynopsisdiv>
55
56 <refsect1>
57 <title>Description</title>
58
59 <para><function>sd_event_source_set_enabled()</function> may be
60 used to enable or disable the event source object specified as
61 <parameter>source</parameter>. The <parameter>enabled</parameter>
62 parameter takes one of <constant>SD_EVENT_ON</constant> (to
63 enable), <constant>SD_EVENT_OFF</constant> (to disable) or
64 <constant>SD_EVENT_ONESHOT</constant>. If invoked with
65 <constant>SD_EVENT_ONESHOT</constant> the event source will be
66 enabled but automatically reset to
67 <constant>SD_EVENT_OFF</constant> after the event source was
68 dispatched once.</para>
69
70 <para>Event sources that are disabled will not result in event
71 loop wakeups and will not be dispatched, until they are enabled
72 again.</para>
73
74 <para><function>sd_event_source_get_enabled()</function> may be
75 used to query whether the event source object
76 <parameter>source</parameter> is currently enabled or not. It
08c1eb0e
ZJS
77 returns the enablement state (one of <constant>SD_EVENT_ON</constant>,
78 <constant>SD_EVENT_OFF</constant>, <constant>SD_EVENT_ONESHOT</constant>)
79 in <parameter>enabled</parameter>, if it is not <constant>NULL</constant>.
80 It also returns true if the event source is not disabled.</para>
dc83f27a
LP
81
82 <para>Event source objects are enabled when they are first created
83 with calls such as
84 <citerefentry><refentrytitle>sd_event_add_io</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
85 <citerefentry><refentrytitle>sd_event_add_time</refentrytitle><manvolnum>3</manvolnum></citerefentry>. However,
7f3fdb7f 86 depending on the event source type they are enabled continuously
dc83f27a
LP
87 (<constant>SD_EVENT_ON</constant>) or only for a single invocation
88 of the event source handler
89 (<constant>SD_EVENT_ONESHOT</constant>). For details see the
90 respective manual pages.</para>
91
92 <para>As event source objects stay active and may be dispatched as
93 long as there is at least one reference to them, in many cases it
94 is a good idea to combine a call to
95 <citerefentry><refentrytitle>sd_event_source_unref</refentrytitle><manvolnum>3</manvolnum></citerefentry>
96 with a prior call to
97 <function>sd_event_source_set_enabled()</function> with
98 <constant>SD_EVENT_OFF</constant>, to ensure the event source is
99 not dispatched again until all other remaining references are dropped.</para>
100 </refsect1>
101
102 <refsect1>
103 <title>Return Value</title>
104
08c1eb0e
ZJS
105 <para>On success, <function>sd_event_source_set_enabled()</function> returns a non-negative
106 integer. <function>sd_event_source_get_enabled()</function> returns zero if the source is
107 disabled (<constant>SD_EVENT_OFF</constant>) and a positive integer otherwise. On failure, they
108 return a negative errno-style error code.</para>
dc83f27a
LP
109 </refsect1>
110
111 <refsect1>
112 <title>Errors</title>
113
114 <para>Returned errors may indicate the following problems:</para>
115
116 <variablelist>
117 <varlistentry>
118 <term><constant>-EINVAL</constant></term>
119
120 <listitem><para><parameter>source</parameter> is not a valid
121 pointer to an <structname>sd_event_source</structname>
122 object.</para></listitem>
123 </varlistentry>
124
125 <varlistentry>
126 <term><constant>-ENOMEM</constant></term>
127
128 <listitem><para>Not enough memory.</para></listitem>
129 </varlistentry>
130
131 <varlistentry>
132 <term><constant>-ECHILD</constant></term>
133
134 <listitem><para>The event loop has been created in a different process.</para></listitem>
135
136 </varlistentry>
137
138 </variablelist>
139 </refsect1>
140
141 <xi:include href="libsystemd-pkgconfig.xml" />
142
143 <refsect1>
144 <title>See Also</title>
145
146 <para>
147 <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
148 <citerefentry><refentrytitle>sd_event_add_io</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
149 <citerefentry><refentrytitle>sd_event_add_time</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
dc83f27a 150 <citerefentry><refentrytitle>sd_event_add_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
8274a30d
LP
151 <citerefentry><refentrytitle>sd_event_add_child</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
152 <citerefentry><refentrytitle>sd_event_add_inotify</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
dc83f27a
LP
153 <citerefentry><refentrytitle>sd_event_add_defer</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
154 <citerefentry><refentrytitle>sd_event_source_unref</refentrytitle><manvolnum>3</manvolnum></citerefentry>
155 </para>
156 </refsect1>
157
158</refentry>