Is it possible to use rusb after a fork()?
createyourpersonalaccount opened this issue · 2 comments
Hello,
I am trying to use rusb together with daemonize, which forks the process. I have noticed that the crate doesn't work as intended when I do so.
If you could provide some help for me to understand how to do this properly it would be very much appreciated. I think this has something to do with GlobalContext
but I don't understand how to use it across forks.
libusb warns about fork()
but what I want is to delay the initialization of the context until the process is daemonized, which is different, i.e. I don't wish to have libusb or rusb work between parent and child process which is what libusb warns of I believe.
What you mean by "doesn't work as intended"
I can suggest to use Context instead GlobalContext
. And create Context
after fork
My apologies, it works fine.
I was tired and after daemonizing I could not detect certain peripherals... but that's because I had removed them from their buses! So the "bug" was that I forgot that I removed the USBs and then I couldn't detect them...