Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

epoll_ctl - control epoll instance

&pagelevel(4)&pagelevel

Syntax

#include <sys/epoll.h>

int epoll_ctl (int epfd, int op, int fd, struct epoll_event *event)

Description

This system call performs control operations on the epoll instance epfd. It requests that the operation op be performed for the target file descriptor, fd.

Parameter-description:

int op

Valid values for the op argument are :

EPOLL_CTL_ADD

Register the target file descriptor fd on the epoll instance referred to by the file descriptor epfd and associate the event event with the internal file linked to fd.

EPOLL_CTL_MOD

Change the event event associated with the target file descriptor fd.

EPOLL_CTL_DEL

Remove (deregister) the target file descriptor fd from the epoll instance referred to by epfd. The event argument is ignored and can be NULL.

struct epoll_event *event

The event argument describes the events to be monitored for file descriptor fd as well as application specific data, which are to be returned if one of the events occurs.

The struct epoll_event is defined as:

typedef union epoll_data {
   void *ptr;
   int fd;
   uint32_t u32;
   uint64_t u64;
} epoll_data_t;
struct epoll_event {
   uint32_t events; /* Epoll events */
   epoll_data_t data; /* User data variable */
};

The data member can be supplied with application specific data, which contain additional information, e.g. on the file descriptor.

The events member is a bit mask composed using the following available event types:

EPOLLIN

Data other than high-priority data may be read without blocking. For STREAMS, this flag is set in events even if the message is of zero length.

EPOLLPRI


Data other than high-priority data may be read without blocking. For STREAMS, this flag is set in events even if the message is of zero length.

EPOLLOUT

Normal data (priority band equals 0) may be written without blocking.

EPOLLERR

An error has occurred on the device or stream. The function epoll_wait() will always wait for this event; it is not necessary to set it in events for the epoll_ctl() function.

EPOLLHUP

A hangup has occured in the stream. The device has been disconnected.
EPOLLHUP and EPOLLOUT are mutually exclusive; a stream can never be writable if a hangup has occurred. However, this event and EPOLLIN, EPOLLRDNORM, EPOLLRDBAND or EPOLLPRI are not mutually exclusive.
The function epoll_wait() will always wait for this event; it is not necessary to set EPOLLHUP in events for the epoll_ctl() function.

EPOLLRDNORM

Normal data (priority band equals 0) may be read without blocking. For STREAMS, this flag is set in events even if the message is of zero length.

EPOLLWRNORM

as EPOLLOUT.

EPOLLRDBAND

Data from a non-zero priority band may be read without blocking. For STREAMS, this flag is set in events even if the message is of zero length.

EPOLLWRBAND

Priority data (priority band > 0) may be written.

EPOLLRDHUP

as EPOLLHUP.

EPOLLET

This functionality is not supported in POSIX.

Returnwert

0

if successful.

 

-1

if an error occurs; errno is set to indicate the error.

Fehler

epoll_ctl() will fail if:

 

EBADF

epfd or fd is not a valid file descriptor.

 

ENOENT

op was EPOLL_CTL_MOD or EPOLL_CTL_DEL, and fd is not registered with the epoll instance epfd.

 

EEXIST

op was EPOLL_CTL_ADD, and the supplied file descriptor fd is already registered with the epoll instance epfd.

 

EINVAL

epfd is not an epoll file desriptor, or fd is the same as epfd, or the requested operation op is not supported by this interface.

See also

epoll_create(), epoll_wait()