Hello,

Bin Liu wrote:
> >> >There's still a bit of a race condition here, isn't there?
> >> >
> >> >Is there any good way to deal with that?
> >>
> >> What race condition are you seeing here?
> >
> > USB cable is unplugged
> 
> Assuming /dev/ttyUSB0 is opened by process ATM.
> 
> >  Process is sent SIGHUP
> > USB cable is quickly replugged
> 
> /dev/ttyUSB0 is still open, so /dev/ttyUSB1 is created.
> 
> >  Process closes port
> 
> Process closes /dev/ttyUSB0.

Right - this is the race condition I'm talking about.

I know that the kernel will reuse ttyUSB0 *next time* because then,
the process has closed it. My question is about dealing with the race
condition between replug and close on the first unplug-replug cycle.

The kernel could take the stance that it will not try to second-guess
the outside world, but another alternative is to defer the new device
until the old has been closed, or perhaps a timeout.


//Peter
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to