xref: /openbmc/linux/Documentation/userspace-api/media/mediactl/request-func-poll.rst (revision cbecf716ca618fd44feda6bd9a64a8179d031fc5)
184d33341SMauro Carvalho Chehab.. SPDX-License-Identifier: GPL-2.0 OR GFDL-1.1-no-invariants-or-later
2*937e6805SMauro Carvalho Chehab.. c:namespace:: MC
354f38fcaSMauro Carvalho Chehab
454f38fcaSMauro Carvalho Chehab.. _request-func-poll:
554f38fcaSMauro Carvalho Chehab
654f38fcaSMauro Carvalho Chehab**************
754f38fcaSMauro Carvalho Chehabrequest poll()
854f38fcaSMauro Carvalho Chehab**************
954f38fcaSMauro Carvalho Chehab
1054f38fcaSMauro Carvalho ChehabName
1154f38fcaSMauro Carvalho Chehab====
1254f38fcaSMauro Carvalho Chehab
1354f38fcaSMauro Carvalho Chehabrequest-poll - Wait for some event on a file descriptor
1454f38fcaSMauro Carvalho Chehab
1554f38fcaSMauro Carvalho ChehabSynopsis
1654f38fcaSMauro Carvalho Chehab========
1754f38fcaSMauro Carvalho Chehab
1854f38fcaSMauro Carvalho Chehab.. code-block:: c
1954f38fcaSMauro Carvalho Chehab
2054f38fcaSMauro Carvalho Chehab    #include <sys/poll.h>
2154f38fcaSMauro Carvalho Chehab
2254f38fcaSMauro Carvalho Chehab.. c:function:: int poll( struct pollfd *ufds, unsigned int nfds, int timeout )
2354f38fcaSMauro Carvalho Chehab
2454f38fcaSMauro Carvalho ChehabArguments
2554f38fcaSMauro Carvalho Chehab=========
2654f38fcaSMauro Carvalho Chehab
2754f38fcaSMauro Carvalho Chehab``ufds``
2854f38fcaSMauro Carvalho Chehab   List of file descriptor events to be watched
2954f38fcaSMauro Carvalho Chehab
3054f38fcaSMauro Carvalho Chehab``nfds``
3154f38fcaSMauro Carvalho Chehab   Number of file descriptor events at the \*ufds array
3254f38fcaSMauro Carvalho Chehab
3354f38fcaSMauro Carvalho Chehab``timeout``
3454f38fcaSMauro Carvalho Chehab   Timeout to wait for events
3554f38fcaSMauro Carvalho Chehab
3654f38fcaSMauro Carvalho ChehabDescription
3754f38fcaSMauro Carvalho Chehab===========
3854f38fcaSMauro Carvalho Chehab
39*937e6805SMauro Carvalho ChehabWith the :c:func:`poll()` function applications can wait
4054f38fcaSMauro Carvalho Chehabfor a request to complete.
4154f38fcaSMauro Carvalho Chehab
42*937e6805SMauro Carvalho ChehabOn success :c:func:`poll()` returns the number of file
4354f38fcaSMauro Carvalho Chehabdescriptors that have been selected (that is, file descriptors for which the
4454f38fcaSMauro Carvalho Chehab``revents`` field of the respective struct :c:type:`pollfd`
4554f38fcaSMauro Carvalho Chehabis non-zero). Request file descriptor set the ``POLLPRI`` flag in ``revents``
4654f38fcaSMauro Carvalho Chehabwhen the request was completed.  When the function times out it returns
4754f38fcaSMauro Carvalho Chehaba value of zero, on failure it returns -1 and the ``errno`` variable is
4854f38fcaSMauro Carvalho Chehabset appropriately.
4954f38fcaSMauro Carvalho Chehab
5054f38fcaSMauro Carvalho ChehabAttempting to poll for a request that is not yet queued will
5154f38fcaSMauro Carvalho Chehabset the ``POLLERR`` flag in ``revents``.
5254f38fcaSMauro Carvalho Chehab
5354f38fcaSMauro Carvalho ChehabReturn Value
5454f38fcaSMauro Carvalho Chehab============
5554f38fcaSMauro Carvalho Chehab
56*937e6805SMauro Carvalho ChehabOn success, :c:func:`poll()` returns the number of
5754f38fcaSMauro Carvalho Chehabstructures which have non-zero ``revents`` fields, or zero if the call
5854f38fcaSMauro Carvalho Chehabtimed out. On error -1 is returned, and the ``errno`` variable is set
5954f38fcaSMauro Carvalho Chehabappropriately:
6054f38fcaSMauro Carvalho Chehab
6154f38fcaSMauro Carvalho Chehab``EBADF``
6254f38fcaSMauro Carvalho Chehab    One or more of the ``ufds`` members specify an invalid file
6354f38fcaSMauro Carvalho Chehab    descriptor.
6454f38fcaSMauro Carvalho Chehab
6554f38fcaSMauro Carvalho Chehab``EFAULT``
6654f38fcaSMauro Carvalho Chehab    ``ufds`` references an inaccessible memory area.
6754f38fcaSMauro Carvalho Chehab
6854f38fcaSMauro Carvalho Chehab``EINTR``
6954f38fcaSMauro Carvalho Chehab    The call was interrupted by a signal.
7054f38fcaSMauro Carvalho Chehab
7154f38fcaSMauro Carvalho Chehab``EINVAL``
7254f38fcaSMauro Carvalho Chehab    The ``nfds`` value exceeds the ``RLIMIT_NOFILE`` value. Use
7354f38fcaSMauro Carvalho Chehab    ``getrlimit()`` to obtain this value.
74