linux - Detect if an open file/device has been replaced/deleted -


assume following situation under linux:

a process continuously reading usb-serial converter device (/dev/ttyusb0). device suddenly unplugged , plugged in again (or resetting reason). process continues have valid file handle /dev/ttyusb0 won't receive data device unless process re-opens device (because udev has deleted , re-created device node).

is there direct way detect such situation (ie. not indirectly detecting timeout in data flow) process knows has re-open device? reliable monitor modification time of /dev/ttyusb0 using stat()?

additional details:

the process opens device file using standard open() function.

/dev tmpfs controlled udev.

note: not want use udev rules , prefer solution implemented directly in process.

if usb device hot-unplugged, operations on device begin failing -eio; can detect , take appropriate action.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -