Skip to contentSkip to conversation

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

DISCUSSION Robert Hancock 1 participant 1 message Mar 9, 2005 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 6 lines · Joerg Pommnitz

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..

Signature · 3 lines
Robert Hancock      Saskatoon, SK, Canada
To email, remove "nospam" from [email protected]
Home Page: http://www.roberthancock.com/