162306a36Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
262306a36Sopenharmony_ci.. c:namespace:: CEC
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci.. _cec-func-poll:
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci**********
762306a36Sopenharmony_cicec poll()
862306a36Sopenharmony_ci**********
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ciName
1162306a36Sopenharmony_ci====
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_cicec-poll - Wait for some event on a file descriptor
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ciSynopsis
1662306a36Sopenharmony_ci========
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci.. code-block:: c
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci    #include <sys/poll.h>
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci.. c:function:: int poll( struct pollfd *ufds, unsigned int nfds, int timeout )
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ciArguments
2562306a36Sopenharmony_ci=========
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci``ufds``
2862306a36Sopenharmony_ci   List of FD events to be watched
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ci``nfds``
3162306a36Sopenharmony_ci   Number of FD events at the \*ufds array
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci``timeout``
3462306a36Sopenharmony_ci   Timeout to wait for events
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ciDescription
3762306a36Sopenharmony_ci===========
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ciWith the :c:func:`poll()` function applications can wait for CEC
4062306a36Sopenharmony_cievents.
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ciOn success :c:func:`poll()` returns the number of file descriptors
4362306a36Sopenharmony_cithat have been selected (that is, file descriptors for which the
4462306a36Sopenharmony_ci``revents`` field of the respective struct :c:type:`pollfd`
4562306a36Sopenharmony_ciis non-zero). CEC devices set the ``POLLIN`` and ``POLLRDNORM`` flags in
4662306a36Sopenharmony_cithe ``revents`` field if there are messages in the receive queue. If the
4762306a36Sopenharmony_citransmit queue has room for new messages, the ``POLLOUT`` and
4862306a36Sopenharmony_ci``POLLWRNORM`` flags are set. If there are events in the event queue,
4962306a36Sopenharmony_cithen the ``POLLPRI`` flag is set. When the function times out it returns
5062306a36Sopenharmony_cia value of zero, on failure it returns -1 and the ``errno`` variable is
5162306a36Sopenharmony_ciset appropriately.
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_ciFor more details see the :c:func:`poll()` manual page.
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ciReturn Value
5662306a36Sopenharmony_ci============
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_ciOn success, :c:func:`poll()` returns the number structures which have
5962306a36Sopenharmony_cinon-zero ``revents`` fields, or zero if the call timed out. On error -1
6062306a36Sopenharmony_ciis returned, and the ``errno`` variable is set appropriately:
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_ci``EBADF``
6362306a36Sopenharmony_ci    One or more of the ``ufds`` members specify an invalid file
6462306a36Sopenharmony_ci    descriptor.
6562306a36Sopenharmony_ci
6662306a36Sopenharmony_ci``EFAULT``
6762306a36Sopenharmony_ci    ``ufds`` references an inaccessible memory area.
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_ci``EINTR``
7062306a36Sopenharmony_ci    The call was interrupted by a signal.
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ci``EINVAL``
7362306a36Sopenharmony_ci    The ``nfds`` value exceeds the ``RLIMIT_NOFILE`` value. Use
7462306a36Sopenharmony_ci    ``getrlimit()`` to obtain this value.
75