Linux – Does ‘epoll_wait’ mean which event was triggered when both EPOLLIN and EPOLLOUT were added?

Does ‘epoll_wait’ mean which event was triggered when both EPOLLIN and EPOLLOUT were added?… here is a solution to the problem.

Does ‘epoll_wait’ mean which event was triggered when both EPOLLIN and EPOLLOUT were added?

SUPPOSE I SPECIFY THE EPOLLIN AND EPOLLOUT FLAGS WHEN ADDING DESCRIPTORS TO MONITOR USING epoll_wait. From the “epoll” online help page, it is not clear what each epoll_event structure returned as part of an array carries in its events field. Quote:

the events member will contain the returned event bit field.

Does this mean that it is impossible to distinguish whether the triggered event represents “writable” or “readable”? There is basically an event mask, logically I want the returned array to represent exactly what event “happened” on the file descriptor?

Solution

Your expectations are correct. The events member will contain the events that occurred for the file descriptor.

Related Problems and Solutions