В кодовой базе, над которой я работаю, используется
function to check whether file descriptors can be read from. One of these file descriptors is a USB device we communicate with directly, and I need to detect when it gets physically disconnected from the computer. However, the program crashes while waiting for file descriptors. When debugging, I get a message "Exception has occurred" along with a "continued" or "Hangup" note, but it's not a real exception I can catch (obviously, since I'm using a C function, despite this being a C++ program). How can I prevent my program from crashing and ideally detect that the device was disconnected (i.e. the fd gets deleted)? We only need to support Linux if it matters.
I tried catching the exception and reading the returned value along with error codes.
Источник:
https://stackoverflow.com/questions/781 ... pulled-out