freeing device file handle upon device unplugging?
Adam Lackorzynski
adam at os.inf.tu-dresden.de
Mon Jul 19 16:42:56 UTC 2010
Hi Alexander,
On Mon Jul 19, 2010 at 08:43:56 +0200, Alexander Stein wrote:
> > /* check if device is ok, if not, try to open it */
> > if (!get_device_status(portfd_connected)) {
> > - if (open_term(0, 0) < 0) {
> > + /* Ok, it's gone, most probably someone unplugged the USB-serial, we
> > + * need to free the FD so that a replug can get the same device
> > + * filename, open it again and be back */
> > + int reopen = portfd == -1;
> > + close(portfd);
> > + lockfile_remove();
> > + portfd = -1;
> > + if (open_term(reopen, reopen, 1) < 0) {
> > if (!error_on_open_window)
> > error_on_open_window = mc_tell(_("Cannot open %s!"), dial_tty);
> > } else {
>
> This works great. Even the reconnection runs smoothly. There is just one small
> drawback which might not be solvable: If the message box appears that the
> device can't be opened, it doesn't not get "removed" if there is a
> reconnection. On other words, if there is no new output one doesn't know that
> there is a reconnection.
Hmm, (unfortunately) works for me. There's even code that handles the
window removal (right below the quoted patch snippet). I've committed
the patch to the repo, could you maybe retry with this version?
Adam
--
Adam adam at os.inf.tu-dresden.de
Lackorzynski http://os.inf.tu-dresden.de/~adam/
More information about the minicom-devel
mailing list