The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
poll.h
Go to the documentation of this file.
1#pragma once
2
3/**
4 * @file poll.h
5 * @brief waiting for file descriptors to become ready.
6 *
7 * the event bits and struct pollfd are ABI and must match the kernel side
8 * in src/kernel/vfs/poll.h and sys_io.c.
9 */
10
11#define POLLIN 0x001 // data to read (or end of file)
12#define POLLPRI 0x002 // urgent data (never set)
13#define POLLOUT 0x004 // room to write
14#define POLLERR 0x008 // an error (a pipe with no reader left)
15#define POLLHUP 0x010 // hung up (a pipe with no writer left)
16#define POLLNVAL 0x020 // not an open descriptor
17
18typedef unsigned int nfds_t;
19
20struct pollfd
21{
22 int fd; // descriptor to watch (negative: ignored)
23 short events; // events to watch for
24 short revents; // events that happened (set by poll)
25};
26
27/**
28 * wait until one of a set of descriptors is ready.
29 * @param fds the descriptors (at most 64).
30 * @param nfds the number of entries.
31 * @param timeout milliseconds to wait; negative waits without limit, 0
32 * does not wait.
33 * @return the number of entries with revents set, 0 on timeout, or -1
34 * (errno set).
35 */
36int poll(struct pollfd *fds, nfds_t nfds, int timeout);
unsigned int nfds_t
Definition poll.h:18
int poll(struct pollfd *fds, nfds_t nfds, int timeout)
wait until one of a set of descriptors is ready.
Definition poll.h:21
int fd
Definition poll.h:22
short revents
Definition poll.h:24
short events
Definition poll.h:23