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