Hello everyone I have this program,
Code:
int fd;
fd_set rd_set;
struct timeval to;
char data[128];
to.tv_sec = 5;
to.tv_usec = 50;
fd = open("/dev/misc/gpio", O_RDWR);
while (1)
{
FD_ZERO(&rd_set);
FD_SET(fd, &rd_set);
s32ret = select(fd+1, &rd_set, NULL, NULL, &to);
if (s32ret < 0)
{
printf("select() error\n");
break;
}
else if (s32ret == 0)
{
printf("select() timeout\n");
continue;
}
else
{
if (FD_ISSET(fd, &rd_set))
{
/* do my stuff */
}
}
}
My problem is after the first 5 seconds of waiting, the timeout values does not take effect anymore on the select() call. There will be a tight loop on the else-if part. Sometimes the select() is successful but on other times it returns zero without even waiting. What could be the problem here?