1*4882a593Smuzhiyun.. SPDX-License-Identifier: GPL-2.0 OR GFDL-1.1-no-invariants-or-later 2*4882a593Smuzhiyun.. c:namespace:: MC 3*4882a593Smuzhiyun 4*4882a593Smuzhiyun.. _request-func-poll: 5*4882a593Smuzhiyun 6*4882a593Smuzhiyun************** 7*4882a593Smuzhiyunrequest poll() 8*4882a593Smuzhiyun************** 9*4882a593Smuzhiyun 10*4882a593SmuzhiyunName 11*4882a593Smuzhiyun==== 12*4882a593Smuzhiyun 13*4882a593Smuzhiyunrequest-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 file descriptor events to be watched 29*4882a593Smuzhiyun 30*4882a593Smuzhiyun``nfds`` 31*4882a593Smuzhiyun Number of file descriptor 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 40*4882a593Smuzhiyunfor a request to complete. 41*4882a593Smuzhiyun 42*4882a593SmuzhiyunOn success :c:func:`poll()` returns the number of file 43*4882a593Smuzhiyundescriptors that 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). Request file descriptor set the ``POLLPRI`` flag in ``revents`` 46*4882a593Smuzhiyunwhen the request was completed. When the function times out it returns 47*4882a593Smuzhiyuna value of zero, on failure it returns -1 and the ``errno`` variable is 48*4882a593Smuzhiyunset appropriately. 49*4882a593Smuzhiyun 50*4882a593SmuzhiyunAttempting to poll for a request that is not yet queued will 51*4882a593Smuzhiyunset the ``POLLERR`` flag in ``revents``. 52*4882a593Smuzhiyun 53*4882a593SmuzhiyunReturn Value 54*4882a593Smuzhiyun============ 55*4882a593Smuzhiyun 56*4882a593SmuzhiyunOn success, :c:func:`poll()` returns the number of 57*4882a593Smuzhiyunstructures which have non-zero ``revents`` fields, or zero if the call 58*4882a593Smuzhiyuntimed out. On error -1 is returned, and the ``errno`` variable is set 59*4882a593Smuzhiyunappropriately: 60*4882a593Smuzhiyun 61*4882a593Smuzhiyun``EBADF`` 62*4882a593Smuzhiyun One or more of the ``ufds`` members specify an invalid file 63*4882a593Smuzhiyun descriptor. 64*4882a593Smuzhiyun 65*4882a593Smuzhiyun``EFAULT`` 66*4882a593Smuzhiyun ``ufds`` references an inaccessible memory area. 67*4882a593Smuzhiyun 68*4882a593Smuzhiyun``EINTR`` 69*4882a593Smuzhiyun The call was interrupted by a signal. 70*4882a593Smuzhiyun 71*4882a593Smuzhiyun``EINVAL`` 72*4882a593Smuzhiyun The ``nfds`` value exceeds the ``RLIMIT_NOFILE`` value. Use 73*4882a593Smuzhiyun ``getrlimit()`` to obtain this value. 74