I'm sorry to say that I'm so stone age that I don't even know what language that is.
It looks like you are trying to read from all the event streams sequentially.
struct pollfd pfds[4];
pfds[0].fd=open(etc...);
pfds[0].events=POLLIN|POLLERR;
pfds[1].fd=open(etc...);
pfds[1].events=POLLIN|POLLERR;
pfds[2].fd=open(etc...);
pfds[2].events=POLLIN|POLLERR;
pfds[3].fd=open(etc...);
pfds[3].events=POLLIN|POLLERR;
for(;;)
{
code=poll(pfds, 4, -1);
if (code<0) break;
for(i=0;i<4;i++)
{
if (pfds[i].revents&(POLLIN|POLLERR))
{
/* read & do something */
}
}
}
Here's how we do it with stone axes.