Memory handling with struct epoll_event

It's absolutely fine to immediately throw away or reuse your epoll_event struct.

The kernel will copy the parameters out of the epoll_event struct.

This is exactly the same as if you used an ioctl which takes a struct as a parameter, or a socket operation (e.g. bind) which takes a struct sockaddr_in.

The kernel takes what it needs, and it's immediately ok for you to free it.

The only thing you need to worry about is the "user data", which is only relevant to you. The kernel will store it, but you need to know what it means when you get an event.


Everything is fine. The epoll_ctl function is a simple wrapper around a system call which will be entirely complete when the function returns. No further data from userspace is required. The struct is simply a way to package the arguments.

Tags:

Linux

C

Epoll