Dmitry Torokhov wrote:
You should be able to poll (select) /proc/bus/input/devices.
Yeah that would be great; anyway, I tried and... well nothing happens. I
am obviously missing something here:
#include <poll.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
int main()
{
int fd, c;
struct pollfd pfd;
fd=open("/proc/bus/input/devices", O_RDONLY);
if(fd==-1)
return -1;
pfd.fd=fd;
pfd.events=POLLIN;
while(1) {
c=poll(&pfd, 1, 20000);
if(c==-1)
printf("Error polling\n");
else if(c==0)
printf("Timeout\n");
else
printf("Something changed");
}
}
The result, while I detach or attach new devices is:
Timeout
Timeout
Timeout
Timeout
Timeout
bye
Alessio