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