2016-07-08 20:55:42 +02:00
.. -*- coding: utf-8; mode: rst -*-
.. _cec-func-poll:
***** *****
cec poll()
***** *****
2016-07-08 20:55:43 +02:00
Name
====
2016-07-08 20:55:42 +02:00
2016-07-08 20:55:43 +02:00
cec-poll - Wait for some event on a file descriptor
2016-07-08 20:55:42 +02:00
Synopsis
========
.. code-block :: c
#include <sys/poll.h>
2016-08-19 12:00:43 -03:00
.. c:function :: int poll( struct pollfd *ufds, unsigned int nfds, int timeout )
2016-08-19 16:58:14 -03:00
:name: cec-poll
2016-07-08 20:55:43 +02:00
Arguments
=========
2016-08-19 16:58:14 -03:00
`` ufds ``
List of FD events to be watched
`` nfds ``
2017-02-27 10:14:55 -03:00
Number of FD events at the \*ufds array
2016-08-19 16:58:14 -03:00
`` timeout ``
Timeout to wait for events
2016-07-08 20:55:42 +02:00
Description
===========
2017-07-28 06:31:50 -04:00
With the :c:func: `poll() <cec-poll>` function applications can wait for CEC
2016-07-08 20:55:42 +02:00
events.
2017-07-28 06:31:50 -04:00
On success :c:func: `poll() <cec-poll>` returns the number of file descriptors
2016-07-08 20:55:42 +02:00
that have been selected (that is, file descriptors for which the
2016-09-08 05:48:50 -03:00
`` revents `` field of the respective struct :c:type: `pollfd`
2016-07-08 20:55:42 +02:00
is non-zero). CEC devices set the `` POLLIN `` and `` POLLRDNORM `` flags in
the `` revents `` field if there are messages in the receive queue. If the
transmit queue has room for new messages, the `` POLLOUT `` and
`` POLLWRNORM `` flags are set. If there are events in the event queue,
2017-02-27 10:14:55 -03:00
then the `` POLLPRI `` flag is set. When the function times out it returns
2016-07-08 20:55:42 +02:00
a value of zero, on failure it returns -1 and the `` errno `` variable is
set appropriately.
2017-07-28 06:31:50 -04:00
For more details see the :c:func: `poll() <cec-poll>` manual page.
2016-07-08 20:55:42 +02:00
Return Value
============
2017-07-28 06:31:50 -04:00
On success, :c:func: `poll() <cec-poll>` returns the number structures which have
2016-07-08 20:55:42 +02:00
non-zero `` revents `` fields, or zero if the call timed out. On error -1
is returned, and the `` errno `` variable is set appropriately:
2016-07-08 17:59:27 -03:00
`` EBADF ``
2016-07-08 20:55:42 +02:00
One or more of the `` ufds `` members specify an invalid file
descriptor.
2016-07-08 17:59:27 -03:00
`` EFAULT ``
2016-07-08 20:55:42 +02:00
`` ufds `` references an inaccessible memory area.
2016-07-08 17:59:27 -03:00
`` EINTR ``
2016-07-08 20:55:42 +02:00
The call was interrupted by a signal.
2016-07-08 17:59:27 -03:00
`` EINVAL ``
2016-07-08 20:55:42 +02:00
The `` nfds `` argument is greater than `` OPEN_MAX `` .