^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) .. c:namespace:: CEC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) .. _cec-func-poll:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) **********
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) cec poll()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) **********
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) Name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) ====
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) cec-poll - Wait for some event on a file descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) Synopsis
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) ========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) .. code-block:: c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <sys/poll.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) .. c:function:: int poll( struct pollfd *ufds, unsigned int nfds, int timeout )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) Arguments
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) =========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) ``ufds``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) List of FD events to be watched
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) ``nfds``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) Number of FD events at the \*ufds array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) ``timeout``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) Timeout to wait for events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) Description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) ===========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) With the :c:func:`poll()` function applications can wait for CEC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) events.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) On success :c:func:`poll()` returns the number of file descriptors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) that have been selected (that is, file descriptors for which the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) ``revents`` field of the respective struct :c:type:`pollfd`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) is non-zero). CEC devices set the ``POLLIN`` and ``POLLRDNORM`` flags in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) the ``revents`` field if there are messages in the receive queue. If the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) transmit queue has room for new messages, the ``POLLOUT`` and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) ``POLLWRNORM`` flags are set. If there are events in the event queue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) then the ``POLLPRI`` flag is set. When the function times out it returns
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) a value of zero, on failure it returns -1 and the ``errno`` variable is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) set appropriately.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) For more details see the :c:func:`poll()` manual page.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) Return Value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) ============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) On success, :c:func:`poll()` returns the number structures which have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) non-zero ``revents`` fields, or zero if the call timed out. On error -1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) is returned, and the ``errno`` variable is set appropriately:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) ``EBADF``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) One or more of the ``ufds`` members specify an invalid file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) descriptor.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) ``EFAULT``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) ``ufds`` references an inaccessible memory area.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) ``EINTR``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) The call was interrupted by a signal.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) ``EINVAL``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) The ``nfds`` value exceeds the ``RLIMIT_NOFILE`` value. Use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) ``getrlimit()`` to obtain this value.