我正在 hidraw 驱动程序下为 USB 设备实现基于 libudev 的监控代码。我已经实现了网络上的标准示例,并使用 valgrind 和 gdb 检查了内存泄漏。
/*******************************************
libudev example.
This example prints out properties of
each of the hidraw devices. It then
creates a monitor which will report when
hidraw devices are connected or removed
from the system.
This code is meant to be a teaching
resource. It can be used for anyone for
any reason, including embedding into
a commercial product.
The document describing this file, and
updated versions can be found at:
http://www.signal11.us/oss/udev/ …
Run Code Online (Sandbox Code Playgroud)