]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-event: explicit document what to do with epoll-incompatible fds 28767/head
authorLennart Poettering <lennart@poettering.net>
Thu, 10 Aug 2023 13:01:16 +0000 (15:01 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 10 Aug 2023 13:02:03 +0000 (15:02 +0200)
man/sd_event_add_io.xml

index 4201c68f0d0db624df35676821f8f13014f4ef1d..d5495732a79e5c28f60a3ac82e81ad732c8dac7e 100644 (file)
   <refsect1>
     <title>Description</title>
 
-    <para><function>sd_event_add_io()</function> adds a new I/O event
-    source to an event loop. The event loop object is specified in the
-    <parameter>event</parameter> parameter, the event source object is
-    returned in the <parameter>source</parameter> parameter. The
-    <parameter>fd</parameter> parameter takes the UNIX file descriptor
-    to watch, which may refer to a socket, a FIFO, a message queue, a
-    serial connection, a character device, or any other file descriptor
-    compatible with Linux
-    <citerefentry project='man-pages'><refentrytitle>epoll</refentrytitle><manvolnum>7</manvolnum></citerefentry>. The
-    <parameter>events</parameter> parameter takes a bit mask of events
-    to watch for, a combination of the following event flags:
-    <constant>EPOLLIN</constant>, <constant>EPOLLOUT</constant>,
-    <constant>EPOLLRDHUP</constant>, <constant>EPOLLPRI</constant>,
-    and <constant>EPOLLET</constant>, see
-    <citerefentry project='man-pages'><refentrytitle>epoll_ctl</refentrytitle><manvolnum>2</manvolnum></citerefentry>
-    for details.</para>
+    <para><function>sd_event_add_io()</function> adds a new I/O event source to an event loop. The event loop
+    object is specified in the <parameter>event</parameter> parameter, the event source object is returned in
+    the <parameter>source</parameter> parameter. The <parameter>fd</parameter> parameter takes the UNIX file
+    descriptor to watch, which may refer to a socket, a FIFO, a message queue, a serial connection, a
+    character device, or any other file descriptor compatible with Linux <citerefentry
+    project='man-pages'><refentrytitle>epoll</refentrytitle><manvolnum>7</manvolnum></citerefentry>. The
+    <parameter>events</parameter> parameter takes a bit mask of events to watch for, a combination of the
+    following event flags: <constant>EPOLLIN</constant>, <constant>EPOLLOUT</constant>,
+    <constant>EPOLLRDHUP</constant>, <constant>EPOLLPRI</constant>, and <constant>EPOLLET</constant>, see
+    <citerefentry
+    project='man-pages'><refentrytitle>epoll_ctl</refentrytitle><manvolnum>2</manvolnum></citerefentry> for
+    details. Note that not all file descriptors are compatible with epoll, for example regular file or
+    directories are not. If this function is called with a file descriptor that does not support epoll,
+    <constant>-EPERM</constant> is returned (also see below). In most cases such file descriptors may be
+    treated as always-readable or always-writable, so that IO event watching is unnecessary.</para>
 
     <para>The <parameter>handler</parameter> is a function to call when the event source is triggered or
     <constant>NULL</constant>. The <parameter>userdata</parameter> pointer will be passed to the handler
 
           <listitem><para>The passed event source is not an I/O event source.</para></listitem>
         </varlistentry>
+
+        <varlistentry>
+          <term><constant>-EPERM</constant></term>
+
+          <listitem><para>The passed file descriptor does not support the <citerefentry
+          project='man-pages'><refentrytitle>epoll</refentrytitle><manvolnum>7</manvolnum></citerefentry>
+          API, for example because it is a regular file or directory. See <citerefentry
+          project='man-pages'><refentrytitle>epoll_ctl</refentrytitle><manvolnum>2</manvolnum></citerefentry>
+          for details.</para></listitem>
+        </varlistentry>
       </variablelist>
     </refsect2>
   </refsect1>