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