191 lines
5.1 KiB
HTML
191 lines
5.1 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of SD_EVENT_SOURCE_SET_ENABLED</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>SD_EVENT_SOURCE_SET_ENABLED</H1>
|
|
Section: sd_event_source_set_enabled (3)<BR>Updated: <BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
sd_event_source_set_enabled, sd_event_source_get_enabled, SD_EVENT_ON, SD_EVENT_OFF, SD_EVENT_ONESHOT - Enable or disable event sources
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<P>
|
|
<B>
|
|
</B><PRE>
|
|
#include <<A HREF="file:///usr/include/systemd/sd-event.h">systemd/sd-event.h</A>>
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
<B>
|
|
</B><PRE>
|
|
enum {
|
|
<B>SD_EVENT_OFF</B> = 0,
|
|
<B>SD_EVENT_ON</B> = 1,
|
|
<B>SD_EVENT_ONESHOT</B> = -1,
|
|
};
|
|
</PRE>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="1">
|
|
<B>int sd_event_source_set_enabled(sd_event_source *</B><I>source</I><B>, int </B><I>enabled</I><B>);</B>
|
|
|
|
<DT id="2">
|
|
<B>int sd_event_source_get_enabled(sd_event_source *</B><I>source</I><B>, int *</B><I>enabled</I><B>);</B>
|
|
|
|
</DL>
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
<P>
|
|
|
|
<B>sd_event_source_set_enabled()</B>
|
|
<DD>may be used to enable or disable the event source object specified as
|
|
<I>source</I>. The
|
|
<I>enabled</I>
|
|
parameter takes one of
|
|
<B>SD_EVENT_ON</B>
|
|
(to enable),
|
|
<B>SD_EVENT_OFF</B>
|
|
(to disable) or
|
|
<B>SD_EVENT_ONESHOT</B>. If invoked with
|
|
<B>SD_EVENT_ONESHOT</B>
|
|
the event source will be enabled but automatically reset to
|
|
<B>SD_EVENT_OFF</B>
|
|
after the event source was dispatched once.
|
|
<P>
|
|
|
|
Event sources that are disabled will not result in event loop wakeups and will not be dispatched, until they are enabled again.
|
|
<P>
|
|
|
|
<B>sd_event_source_get_enabled()</B>
|
|
may be used to query whether the event source object
|
|
<I>source</I>
|
|
is currently enabled or not. It returns the enablement state (one of
|
|
<B>SD_EVENT_ON</B>,
|
|
<B>SD_EVENT_OFF</B>,
|
|
<B>SD_EVENT_ONESHOT</B>) in
|
|
<I>enabled</I>, if it is not
|
|
<B>NULL</B>. It also returns true if the event source is not disabled.
|
|
<P>
|
|
|
|
Event source objects are enabled when they are first created with calls such as
|
|
<B><A HREF="/cgi-bin/man/man2html?3+sd_event_add_io">sd_event_add_io</A></B>(3),
|
|
<B><A HREF="/cgi-bin/man/man2html?3+sd_event_add_time">sd_event_add_time</A></B>(3). However, depending on the event source type they are enabled continuously (<B>SD_EVENT_ON</B>) or only for a single invocation of the event source handler (<B>SD_EVENT_ONESHOT</B>). For details see the respective manual pages.
|
|
<P>
|
|
|
|
As event source objects stay active and may be dispatched as long as there is at least one reference to them, in many cases it is a good idea to combine a call to
|
|
<B><A HREF="/cgi-bin/man/man2html?3+sd_event_source_unref">sd_event_source_unref</A></B>(3)
|
|
with a prior call to
|
|
<B>sd_event_source_set_enabled()</B>
|
|
with
|
|
<B>SD_EVENT_OFF</B>, to ensure the event source is not dispatched again until all other remaining references are dropped.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>RETURN VALUE</H2>
|
|
|
|
<P>
|
|
|
|
On success,
|
|
<B>sd_event_source_set_enabled()</B>
|
|
returns a non-negative integer.
|
|
<B>sd_event_source_get_enabled()</B>
|
|
returns zero if the source is disabled (<B>SD_EVENT_OFF</B>) and a positive integer otherwise. On failure, they return a negative errno-style error code.
|
|
<A NAME="lbAF"> </A>
|
|
<H3>Errors</H3>
|
|
|
|
<P>
|
|
|
|
Returned errors may indicate the following problems:
|
|
<P>
|
|
|
|
<B>-EINVAL</B>
|
|
<DL COMPACT><DT id="3"><DD>
|
|
<I>source</I>
|
|
is not a valid pointer to an
|
|
sd_event_source
|
|
object.
|
|
</DL>
|
|
|
|
<P>
|
|
|
|
<B>-ENOMEM</B>
|
|
<DL COMPACT><DT id="4"><DD>
|
|
Not enough memory.
|
|
</DL>
|
|
|
|
<P>
|
|
|
|
<B>-ECHILD</B>
|
|
<DL COMPACT><DT id="5"><DD>
|
|
The event loop has been created in a different process.
|
|
</DL>
|
|
|
|
<A NAME="lbAG"> </A>
|
|
<H2>NOTES</H2>
|
|
|
|
<P>
|
|
|
|
These APIs are implemented as a shared library, which can be compiled and linked to with the
|
|
<B>libsystemd</B> <B><A HREF="/cgi-bin/man/man2html?1+pkg-config">pkg-config</A></B>(1)
|
|
file.
|
|
<A NAME="lbAH"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<P>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+sd-event">sd-event</A></B>(3),
|
|
<B><A HREF="/cgi-bin/man/man2html?3+sd_event_add_io">sd_event_add_io</A></B>(3),
|
|
<B><A HREF="/cgi-bin/man/man2html?3+sd_event_add_time">sd_event_add_time</A></B>(3),
|
|
<B><A HREF="/cgi-bin/man/man2html?3+sd_event_add_signal">sd_event_add_signal</A></B>(3),
|
|
<B><A HREF="/cgi-bin/man/man2html?3+sd_event_add_child">sd_event_add_child</A></B>(3),
|
|
<B><A HREF="/cgi-bin/man/man2html?3+sd_event_add_inotify">sd_event_add_inotify</A></B>(3),
|
|
<B><A HREF="/cgi-bin/man/man2html?3+sd_event_add_defer">sd_event_add_defer</A></B>(3),
|
|
<B><A HREF="/cgi-bin/man/man2html?3+sd_event_source_unref">sd_event_source_unref</A></B>(3)
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="6"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="7"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="8"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="9"><A HREF="#lbAE">RETURN VALUE</A><DD>
|
|
<DL>
|
|
<DT id="10"><A HREF="#lbAF">Errors</A><DD>
|
|
</DL>
|
|
<DT id="11"><A HREF="#lbAG">NOTES</A><DD>
|
|
<DT id="12"><A HREF="#lbAH">SEE ALSO</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:55 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|