All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alessio Sangalli <alesan@manoweb.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org
Subject: Re: Notification when a new device is added or removed
Date: Sat, 28 Feb 2009 18:58:05 -0800	[thread overview]
Message-ID: <49A9F9BD.2090604@manoweb.com> (raw)
In-Reply-To: <20090228183917.ZZRA012@mailhub.coreip.homeip.net>

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


  reply	other threads:[~2009-03-01  2:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-28  4:35 Notification when a new device is added or removed Alessio Sangalli
2009-03-01  2:39 ` Dmitry Torokhov
2009-03-01  2:58   ` Alessio Sangalli [this message]
2009-03-01 10:23     ` Dmitry Torokhov
2009-03-02 23:41       ` Alessio Sangalli
2009-03-09 12:06       ` Peter Korsgaard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49A9F9BD.2090604@manoweb.com \
    --to=alesan@manoweb.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.