154f38fcaSMauro Carvalho Chehab.. Permission is granted to copy, distribute and/or modify this 254f38fcaSMauro Carvalho Chehab.. document under the terms of the GNU Free Documentation License, 354f38fcaSMauro Carvalho Chehab.. Version 1.1 or any later version published by the Free Software 454f38fcaSMauro Carvalho Chehab.. Foundation, with no Invariant Sections, no Front-Cover Texts 554f38fcaSMauro Carvalho Chehab.. and no Back-Cover Texts. A copy of the license is included at 654f38fcaSMauro Carvalho Chehab.. Documentation/userspace-api/media/fdl-appendix.rst. 754f38fcaSMauro Carvalho Chehab.. 854f38fcaSMauro Carvalho Chehab.. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections 954f38fcaSMauro Carvalho Chehab 1054f38fcaSMauro Carvalho Chehab.. _cec-func-poll: 1154f38fcaSMauro Carvalho Chehab 1254f38fcaSMauro Carvalho Chehab********** 1354f38fcaSMauro Carvalho Chehabcec poll() 1454f38fcaSMauro Carvalho Chehab********** 1554f38fcaSMauro Carvalho Chehab 1654f38fcaSMauro Carvalho ChehabName 1754f38fcaSMauro Carvalho Chehab==== 1854f38fcaSMauro Carvalho Chehab 1954f38fcaSMauro Carvalho Chehabcec-poll - Wait for some event on a file descriptor 2054f38fcaSMauro Carvalho Chehab 2154f38fcaSMauro Carvalho Chehab 2254f38fcaSMauro Carvalho ChehabSynopsis 2354f38fcaSMauro Carvalho Chehab======== 2454f38fcaSMauro Carvalho Chehab 2554f38fcaSMauro Carvalho Chehab.. code-block:: c 2654f38fcaSMauro Carvalho Chehab 2754f38fcaSMauro Carvalho Chehab #include <sys/poll.h> 2854f38fcaSMauro Carvalho Chehab 2954f38fcaSMauro Carvalho Chehab 3054f38fcaSMauro Carvalho Chehab.. c:function:: int poll( struct pollfd *ufds, unsigned int nfds, int timeout ) 3154f38fcaSMauro Carvalho Chehab :name: cec-poll 3254f38fcaSMauro Carvalho Chehab 3354f38fcaSMauro Carvalho ChehabArguments 3454f38fcaSMauro Carvalho Chehab========= 3554f38fcaSMauro Carvalho Chehab 3654f38fcaSMauro Carvalho Chehab``ufds`` 3754f38fcaSMauro Carvalho Chehab List of FD events to be watched 3854f38fcaSMauro Carvalho Chehab 3954f38fcaSMauro Carvalho Chehab``nfds`` 4054f38fcaSMauro Carvalho Chehab Number of FD events at the \*ufds array 4154f38fcaSMauro Carvalho Chehab 4254f38fcaSMauro Carvalho Chehab``timeout`` 4354f38fcaSMauro Carvalho Chehab Timeout to wait for events 4454f38fcaSMauro Carvalho Chehab 4554f38fcaSMauro Carvalho Chehab 4654f38fcaSMauro Carvalho ChehabDescription 4754f38fcaSMauro Carvalho Chehab=========== 4854f38fcaSMauro Carvalho Chehab 4954f38fcaSMauro Carvalho ChehabWith the :c:func:`poll() <cec-poll>` function applications can wait for CEC 5054f38fcaSMauro Carvalho Chehabevents. 5154f38fcaSMauro Carvalho Chehab 5254f38fcaSMauro Carvalho ChehabOn success :c:func:`poll() <cec-poll>` returns the number of file descriptors 5354f38fcaSMauro Carvalho Chehabthat have been selected (that is, file descriptors for which the 5454f38fcaSMauro Carvalho Chehab``revents`` field of the respective struct :c:type:`pollfd` 5554f38fcaSMauro Carvalho Chehabis non-zero). CEC devices set the ``POLLIN`` and ``POLLRDNORM`` flags in 5654f38fcaSMauro Carvalho Chehabthe ``revents`` field if there are messages in the receive queue. If the 5754f38fcaSMauro Carvalho Chehabtransmit queue has room for new messages, the ``POLLOUT`` and 5854f38fcaSMauro Carvalho Chehab``POLLWRNORM`` flags are set. If there are events in the event queue, 5954f38fcaSMauro Carvalho Chehabthen the ``POLLPRI`` flag is set. When the function times out it returns 6054f38fcaSMauro Carvalho Chehaba value of zero, on failure it returns -1 and the ``errno`` variable is 6154f38fcaSMauro Carvalho Chehabset appropriately. 6254f38fcaSMauro Carvalho Chehab 6354f38fcaSMauro Carvalho ChehabFor more details see the :c:func:`poll() <cec-poll>` manual page. 6454f38fcaSMauro Carvalho Chehab 6554f38fcaSMauro Carvalho Chehab 6654f38fcaSMauro Carvalho ChehabReturn Value 6754f38fcaSMauro Carvalho Chehab============ 6854f38fcaSMauro Carvalho Chehab 6954f38fcaSMauro Carvalho ChehabOn success, :c:func:`poll() <cec-poll>` returns the number structures which have 7054f38fcaSMauro Carvalho Chehabnon-zero ``revents`` fields, or zero if the call timed out. On error -1 7154f38fcaSMauro Carvalho Chehabis returned, and the ``errno`` variable is set appropriately: 7254f38fcaSMauro Carvalho Chehab 7354f38fcaSMauro Carvalho Chehab``EBADF`` 7454f38fcaSMauro Carvalho Chehab One or more of the ``ufds`` members specify an invalid file 7554f38fcaSMauro Carvalho Chehab descriptor. 7654f38fcaSMauro Carvalho Chehab 7754f38fcaSMauro Carvalho Chehab``EFAULT`` 7854f38fcaSMauro Carvalho Chehab ``ufds`` references an inaccessible memory area. 7954f38fcaSMauro Carvalho Chehab 8054f38fcaSMauro Carvalho Chehab``EINTR`` 8154f38fcaSMauro Carvalho Chehab The call was interrupted by a signal. 8254f38fcaSMauro Carvalho Chehab 8354f38fcaSMauro Carvalho Chehab``EINVAL`` 8454f38fcaSMauro Carvalho Chehab The ``nfds`` value exceeds the ``RLIMIT_NOFILE`` value. Use 8554f38fcaSMauro Carvalho Chehab ``getrlimit()`` to obtain this value. 86