Reputation: 48330
I want to be able to detect when a new external device is connected to the linux system and upon that send a notification message to a running process.
I was wondering if there is any other solution than periodically scan for /dev/ and detect if anything has changed.
Upvotes: 2
Views: 869
Reputation: 22395
While you can use udev, the underlying mechanism is netlink. Interfaces themselves are not normally in /dev
, but do show up under /sys/class/net
as sub-directories. However, the hotplug.txt gives a good start to inspecting kernel events. Run the sample code and examine the netlink data when an interface is connected. The text is ASCII that any user space application can parse and use.
Upvotes: 3