LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 04-25-2005, 12:40 PM   #1
lordofring
Member
 
Registered: Feb 2005
Posts: 91

Rep: Reputation: 15
how to know a usb device is plugged in/out


Hello,

My application needs to be notified when a usb device is plugged in/out. I know the file /proc/bus/usb/devices is changed whenever a usb device is plugged in/out. But how do I know the file is changed. May I use poll(() function to wait for the file changing? (I don't want to read the file every second to see the chaning.)

Thanks in advance.
 
Old 04-25-2005, 12:49 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,373

Rep: Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962
not sure if you're going from a programming angle with the references to poll() there, but i'd suggest you look toward udev rules, assuming you're using udev of course. in a specific rule you can set a PROGRAM= variable to run a script on a device being connected. not sure about disconnection, as i've never done it, but i expect it's simple.
 
Old 04-25-2005, 01:15 PM   #3
lordofring
Member
 
Registered: Feb 2005
Posts: 91

Original Poster
Rep: Reputation: 15
Your guess is correct. My question is about programming. My application needs to monitor usb devices plugged in/out. And I don't think I can use udev since my kernel is 2.4.28. Thanks anyway.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
USB Mouse only works when plugged into USB PCI Card helliax Slackware 6 12-05-2005 01:18 AM
How do I know if a serial device is plugged in? paul.nel Linux - Hardware 3 10-20-2005 08:54 AM
gdm + not always plugged usb mouse vrana Slackware 5 06-29-2004 12:48 AM
Why does PC hang when USB device is plugged in? DeepSPiN Fedora 1 12-03-2003 10:59 AM
System freezes during boot with USB device plugged in. dhrivnak Slackware 3 10-31-2003 08:55 PM


All times are GMT -5. The time now is 05:20 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration