libusb-1.0 hotplug events stop working in parent after fork(), when child calls libusb_exit()

前端 未结 1 984
天涯浪人
天涯浪人 2021-01-26 13:27

I\'ve been developing an application that monitors the USB device tree using libusb_hotplug_register_callback(). When a device that matches some criteria is attache

相关标签:
1条回答
  • 2021-01-26 14:11

    In general I do not recommend calling fork from an portable libusb program unless fork is immediately followed by exec. This is due to known issues with fork on OS X. The issue was discussed on the libusb-devel mailing list some time ago (2002) and it looks like I forgot to add this caveat to the documentation for libusb-1.0. I recommend using threads instead.

    On Linux we inherit any fork caveats from libudev. I do not see anything in their documentation about fork so I do not know if it should work or not. You can always try with netlink by adding --disable-udev. This option is not recommended for production use but it might help isolate the problem.

    0 讨论(0)
提交回复
热议问题