Re: select(2), usbserial, tty's and disconnect

From: Robert Hancock
Date: Tue Mar 08 2005 - 21:19:09 EST

Joerg Pommnitz wrote:
Hello all,
currently it seems that select keeps blocking when the USB device behind
ttyUSBx gets unplugged. My understanding is, that select should return
when the next call to one of the operations (read/write) will not block.
This is certainly true for failing with ENODEV. So, is this an issue
that will be fixed or should I poll (not the syscall) the device? Or is there another way to monitor for a vanishing tty (it should not be USB specific).

If you just do a blocking read() on the USB serial port, what happens when you pull the device? At one point (2.4.20 is the last I checked) nothing happened when you did this, the process would just sit there forever. There was discussion at one point about doing a tty_hangup() when the USB device was disconnected (this causes the read() to return with 0 bytes and future open attempts to fail), and a patch was put out to do this. I thought this had been merged, but I could be wrong.

I should think that if that works, then your select should be working as well..

Robert Hancock Saskatoon, SK, Canada
To email, remove "nospam" from hancockr@xxxxxxxxxxxxx
Home Page:

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at