Back to home page

OSCL-LXR

 
 

    


0001 .. SPDX-License-Identifier: GPL-2.0 OR GFDL-1.1-no-invariants-or-later
0002 .. c:namespace:: MC
0003 
0004 .. _request-func-poll:
0005 
0006 **************
0007 request poll()
0008 **************
0009 
0010 Name
0011 ====
0012 
0013 request-poll - Wait for some event on a file descriptor
0014 
0015 Synopsis
0016 ========
0017 
0018 .. code-block:: c
0019 
0020     #include <sys/poll.h>
0021 
0022 .. c:function:: int poll( struct pollfd *ufds, unsigned int nfds, int timeout )
0023 
0024 Arguments
0025 =========
0026 
0027 ``ufds``
0028    List of file descriptor events to be watched
0029 
0030 ``nfds``
0031    Number of file descriptor events at the \*ufds array
0032 
0033 ``timeout``
0034    Timeout to wait for events
0035 
0036 Description
0037 ===========
0038 
0039 With the :c:func:`poll()` function applications can wait
0040 for a request to complete.
0041 
0042 On success :c:func:`poll()` returns the number of file
0043 descriptors that have been selected (that is, file descriptors for which the
0044 ``revents`` field of the respective struct :c:type:`pollfd`
0045 is non-zero). Request file descriptor set the ``POLLPRI`` flag in ``revents``
0046 when the request was completed.  When the function times out it returns
0047 a value of zero, on failure it returns -1 and the ``errno`` variable is
0048 set appropriately.
0049 
0050 Attempting to poll for a request that is not yet queued will
0051 set the ``POLLERR`` flag in ``revents``.
0052 
0053 Return Value
0054 ============
0055 
0056 On success, :c:func:`poll()` returns the number of
0057 structures which have non-zero ``revents`` fields, or zero if the call
0058 timed out. On error -1 is returned, and the ``errno`` variable is set
0059 appropriately:
0060 
0061 ``EBADF``
0062     One or more of the ``ufds`` members specify an invalid file
0063     descriptor.
0064 
0065 ``EFAULT``
0066     ``ufds`` references an inaccessible memory area.
0067 
0068 ``EINTR``
0069     The call was interrupted by a signal.
0070 
0071 ``EINVAL``
0072     The ``nfds`` value exceeds the ``RLIMIT_NOFILE`` value. Use
0073     ``getrlimit()`` to obtain this value.