From: Alan Stern > Sent: 10 June 2016 19:43 > Hans de Goede has reported a difficulty in the Linux port of libusb. > When a device is removed, the poll() system call in usbfs starts > returning POLLERR as soon as udev->state is set to > USB_STATE_NOTATTACHED, but the outstanding URBs are not available for > reaping until some time later (after usbdev_remove() has been called). > This is awkward for libusb or other usbfs clients, although not an > insuperable problem. > > At any rate, it's easy to change usbfs so that it returns POLLHUP as > soon as the state becomes USB_STATE_NOTATTACHED but it doesn't return > POLLERR until after the outstanding URBs have completed. That's what > this patch does; it uses the fact that ps->list is always on the > dev->filelist list until usbdev_remove() takes it off, which happens > after all the outstanding URBs have been cancelled. You need some way for the application to clear the POLLHUP indication (at least temporarily) so that it can wait for a further change - be it notification that a URB is now reapable or that all the tidyup is complete. Personally I'd use POLLHUP for device disconnect type errors and leave POLLERR for serious things (like bad fd numbers). David -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html