Re: Notification when a new device is added or removed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux