poll(2) doesn't empty the event queue

Posted by sasayins on Stack Overflow See other posts from Stack Overflow or by sasayins
Published on 2010-06-11T08:01:58Z Indexed on 2010/06/11 8:02 UTC
Read the original article Hit count: 130

Filed under:

Hi,

Im using linux as my programming platform. I am using poll(2) to know if my device is triggering an event.

The first call of poll is ok, it blocks and wait for the event to happen. But in the second poll function call, it will return but it capture the event. Below are my code

ret = poll( fds, 1, 2000); //2 secs timeout

if( fds[0].revents & POLLIN && ret > 0)
{
   printf("event occur\n");
}

It seems the queue/buffer is not empty, im just assuming.

What do you think is the problem?

Thanks.

© Stack Overflow or respective owner

Related posts about linux