O nás     Inzerce     KontaktSpolehlivé informace o IT již od roku 2011
Hledat
Nepřehlédněte: Nejlepší IT: Pozoruhodné IT produkty pro rok 2024 podruhé
Správa dokumentů
Digitální transformace
Informační systémy
Hlavní rubriky: Informační systémy, Mobilní technologie, Datová centra, Sítě, IT bezpečnost, Software, Hardware, Zkušenosti a názory, Speciály

Pozoruhodné IT produkty 2024 podruhé
E-knihy o IT zdarma
Manuál Linux
[Linux manuál]

poll: čekat na nějakou událost v deskriptoru souboru

Originální popis anglicky: poll - wait for some event on a file descriptor

Návod, kniha: Linux Programmer's Manual

STRUČNĚ

#include <sys/poll.h>
 
int poll(struct pollfd *ufds, unsigned int nfds, int timeout);

POPIS / INSTRUKCE

poll is a variation on the theme of select. It specifies an array of nfds structures of type
 
        struct pollfd {
                int fd;           /* file descriptor */
                short events;     /* requested events */
                short revents;    /* returned events */
        };
and a timeout in milliseconds. A negative value means infinite timeout. The field fd contains a file descriptor for an open file. The field events is an input parameter, a bitmask specifying the events the application is interested in. The field revents is an output parameter, filled by the kernel with the events that actually occurred, either of the type requested, or of one of the types POLLERR or POLLHUP or POLLNVAL. (These three bits are meaningless in the events field, and will be set in the revents field whenever the corresponding condition is true.) If none of the events requested (and no error) has occurred for any of the file descriptors, the kernel waits for timeout milliseconds for one of these events to occur. The following possible bits in these masks are defined in <sys/poll.h>
 
    #define POLLIN      0x0001    /* There is data to read */
    #define POLLPRI     0x0002    /* There is urgent data to read */
    #define POLLOUT     0x0004    /* Writing now will not block */
    #define POLLERR     0x0008    /* Error condition */
    #define POLLHUP     0x0010    /* Hung up */
    #define POLLNVAL    0x0020    /* Invalid request: fd not open */
When compiling XPG4.2 source one also has
 
#ifdef _XOPEN_SOURCE
    #define POLLRDNORM  0x0040    /* Normal data may be read */
    #define POLLRDBAND  0x0080    /* Priority data may be read */
    #define POLLWRNORM  0x0100    /* Writing now will not block */
    #define POLLWRBAND  0x0200    /* Priority data may be written */
#endif
Finally, Linux knows about
 
#ifdef _GNU_SOURCE
    #define POLLMSG     0x0400
#endif

NÁVRATOVÁ HODNOTA

On success, a positive number is returned, where the number returned is the number of structures which have non-zero revents fields (in other words, those descriptors with events or errors reported). A value of 0 indicates that the call timed out and no file descriptors have been selected. On error, -1 is returned, and errno is set appropriately.

CHYBY / ERRORY

EBADF
An invalid file descriptor was given in one of the sets.
EFAULT
The array given as argument was not contained in the calling program's address space.
EINTR
A signal occurred before any requested event.
EINVAL
The nfds value exceeds the RLIMIT_NOFILE value.
ENOMEM
There was no space to allocate file descriptor tables.

BUGS

See the BUGS section of select(2).

ODPOVÍDAJÍCÍ

XPG4-UNIX.

DOSTUPNOST

The poll() systemcall was introduced in Linux 2.1.23. The poll() library call was introduced in libc 5.4.28 (and provides emulation using select if your kernel does not have a poll syscall).

SOUVISEJÍCÍ

select(2), select_tut(2)
1997-12-07 Linux 2.1.23
©2011-2024 BusinessIT.cz, ISSN 1805-0522 | Názvy použité v textech mohou být ochrannými známkami příslušných vlastníků.
Provozovatel: Bispiral, s.r.o., kontakt: BusinessIT(at)Bispiral.com | Inzerce: Best Online Media, s.r.o., zuzana@online-media.cz
O vydavateli | Pravidla webu BusinessIT.cz a ochrana soukromí | Používáme účetní program Money S3 | pg(9511)