request-func-poll.rst 1.7 KB

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