1059b1c5bSMauro Carvalho Chehab.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 2*01fae02dSMauro Carvalho Chehab.. c:namespace:: CEC 354f38fcaSMauro Carvalho Chehab 454f38fcaSMauro Carvalho Chehab.. _cec-func-poll: 554f38fcaSMauro Carvalho Chehab 654f38fcaSMauro Carvalho Chehab********** 754f38fcaSMauro Carvalho Chehabcec poll() 854f38fcaSMauro Carvalho Chehab********** 954f38fcaSMauro Carvalho Chehab 1054f38fcaSMauro Carvalho ChehabName 1154f38fcaSMauro Carvalho Chehab==== 1254f38fcaSMauro Carvalho Chehab 1354f38fcaSMauro Carvalho Chehabcec-poll - Wait for some event on a file descriptor 1454f38fcaSMauro Carvalho Chehab 1554f38fcaSMauro Carvalho ChehabSynopsis 1654f38fcaSMauro Carvalho Chehab======== 1754f38fcaSMauro Carvalho Chehab 1854f38fcaSMauro Carvalho Chehab.. code-block:: c 1954f38fcaSMauro Carvalho Chehab 2054f38fcaSMauro Carvalho Chehab #include <sys/poll.h> 2154f38fcaSMauro Carvalho Chehab 2254f38fcaSMauro Carvalho Chehab.. c:function:: int poll( struct pollfd *ufds, unsigned int nfds, int timeout ) 2354f38fcaSMauro Carvalho Chehab 2454f38fcaSMauro Carvalho ChehabArguments 2554f38fcaSMauro Carvalho Chehab========= 2654f38fcaSMauro Carvalho Chehab 2754f38fcaSMauro Carvalho Chehab``ufds`` 2854f38fcaSMauro Carvalho Chehab List of FD events to be watched 2954f38fcaSMauro Carvalho Chehab 3054f38fcaSMauro Carvalho Chehab``nfds`` 3154f38fcaSMauro Carvalho Chehab Number of FD events at the \*ufds array 3254f38fcaSMauro Carvalho Chehab 3354f38fcaSMauro Carvalho Chehab``timeout`` 3454f38fcaSMauro Carvalho Chehab Timeout to wait for events 3554f38fcaSMauro Carvalho Chehab 3654f38fcaSMauro Carvalho ChehabDescription 3754f38fcaSMauro Carvalho Chehab=========== 3854f38fcaSMauro Carvalho Chehab 39*01fae02dSMauro Carvalho ChehabWith the :c:func:`poll()` function applications can wait for CEC 4054f38fcaSMauro Carvalho Chehabevents. 4154f38fcaSMauro Carvalho Chehab 42*01fae02dSMauro Carvalho ChehabOn success :c:func:`poll()` returns the number of file descriptors 4354f38fcaSMauro Carvalho Chehabthat have been selected (that is, file descriptors for which the 4454f38fcaSMauro Carvalho Chehab``revents`` field of the respective struct :c:type:`pollfd` 4554f38fcaSMauro Carvalho Chehabis non-zero). CEC devices set the ``POLLIN`` and ``POLLRDNORM`` flags in 4654f38fcaSMauro Carvalho Chehabthe ``revents`` field if there are messages in the receive queue. If the 4754f38fcaSMauro Carvalho Chehabtransmit queue has room for new messages, the ``POLLOUT`` and 4854f38fcaSMauro Carvalho Chehab``POLLWRNORM`` flags are set. If there are events in the event queue, 4954f38fcaSMauro Carvalho Chehabthen the ``POLLPRI`` flag is set. When the function times out it returns 5054f38fcaSMauro Carvalho Chehaba value of zero, on failure it returns -1 and the ``errno`` variable is 5154f38fcaSMauro Carvalho Chehabset appropriately. 5254f38fcaSMauro Carvalho Chehab 53*01fae02dSMauro Carvalho ChehabFor more details see the :c:func:`poll()` manual page. 5454f38fcaSMauro Carvalho Chehab 5554f38fcaSMauro Carvalho ChehabReturn Value 5654f38fcaSMauro Carvalho Chehab============ 5754f38fcaSMauro Carvalho Chehab 58*01fae02dSMauro Carvalho ChehabOn success, :c:func:`poll()` returns the number structures which have 5954f38fcaSMauro Carvalho Chehabnon-zero ``revents`` fields, or zero if the call timed out. On error -1 6054f38fcaSMauro Carvalho Chehabis returned, and the ``errno`` variable is set appropriately: 6154f38fcaSMauro Carvalho Chehab 6254f38fcaSMauro Carvalho Chehab``EBADF`` 6354f38fcaSMauro Carvalho Chehab One or more of the ``ufds`` members specify an invalid file 6454f38fcaSMauro Carvalho Chehab descriptor. 6554f38fcaSMauro Carvalho Chehab 6654f38fcaSMauro Carvalho Chehab``EFAULT`` 6754f38fcaSMauro Carvalho Chehab ``ufds`` references an inaccessible memory area. 6854f38fcaSMauro Carvalho Chehab 6954f38fcaSMauro Carvalho Chehab``EINTR`` 7054f38fcaSMauro Carvalho Chehab The call was interrupted by a signal. 7154f38fcaSMauro Carvalho Chehab 7254f38fcaSMauro Carvalho Chehab``EINVAL`` 7354f38fcaSMauro Carvalho Chehab The ``nfds`` value exceeds the ``RLIMIT_NOFILE`` value. Use 7454f38fcaSMauro Carvalho Chehab ``getrlimit()`` to obtain this value. 75