xref: /openbmc/linux/Documentation/userspace-api/media/mediactl/request-func-poll.rst (revision 84d333417d5e5945318f62113b8fffc0eb92138c)
1.. SPDX-License-Identifier: GPL-2.0 OR GFDL-1.1-no-invariants-or-later
2
3.. _request-func-poll:
4
5**************
6request poll()
7**************
8
9Name
10====
11
12request-poll - Wait for some event on a file descriptor
13
14
15Synopsis
16========
17
18.. code-block:: c
19
20    #include <sys/poll.h>
21
22
23.. c:function:: int poll( struct pollfd *ufds, unsigned int nfds, int timeout )
24   :name: request-poll
25
26Arguments
27=========
28
29``ufds``
30   List of file descriptor events to be watched
31
32``nfds``
33   Number of file descriptor events at the \*ufds array
34
35``timeout``
36   Timeout to wait for events
37
38
39Description
40===========
41
42With the :c:func:`poll() <request-func-poll>` function applications can wait
43for a request to complete.
44
45On success :c:func:`poll() <request-func-poll>` returns the number of file
46descriptors that have been selected (that is, file descriptors for which the
47``revents`` field of the respective struct :c:type:`pollfd`
48is non-zero). Request file descriptor set the ``POLLPRI`` flag in ``revents``
49when the request was completed.  When the function times out it returns
50a value of zero, on failure it returns -1 and the ``errno`` variable is
51set appropriately.
52
53Attempting to poll for a request that is not yet queued will
54set the ``POLLERR`` flag in ``revents``.
55
56
57Return Value
58============
59
60On success, :c:func:`poll() <request-func-poll>` returns the number of
61structures which have non-zero ``revents`` fields, or zero if the call
62timed out. On error -1 is returned, and the ``errno`` variable is set
63appropriately:
64
65``EBADF``
66    One or more of the ``ufds`` members specify an invalid file
67    descriptor.
68
69``EFAULT``
70    ``ufds`` references an inaccessible memory area.
71
72``EINTR``
73    The call was interrupted by a signal.
74
75``EINVAL``
76    The ``nfds`` value exceeds the ``RLIMIT_NOFILE`` value. Use
77    ``getrlimit()`` to obtain this value.
78