Close master pty on DCD drop if not CLOCAL
This commit is contained in:
@@ -69,8 +69,9 @@ typedef struct {
|
||||
|
||||
struct termios tio;
|
||||
|
||||
int cmcr;
|
||||
volatile int smcr;
|
||||
int cmcr; /* Commanded by ioctl */
|
||||
volatile int smcr; /* Status from modem */
|
||||
int smcr_last;
|
||||
|
||||
volatile int pollin;
|
||||
volatile int error;
|
||||
@@ -223,6 +224,22 @@ static void _update_notify(ttynvt_t * tty, struct fuse_pollhandle *ph)
|
||||
fuse_pollhandle_destroy(tmp_ph);
|
||||
}
|
||||
|
||||
static int _net_read_check_exit(ttynvt_t * tty)
|
||||
{
|
||||
if ((tty->tio.c_cflag & CLOCAL) == 0 &&
|
||||
(tty->smcr_last & TIOCM_CD) != 0 && (tty->smcr & TIOCM_CD) == 0)
|
||||
{
|
||||
/* CLOCAL is not set (i.e. do not ignore modem control lines) AND
|
||||
* DCD dropped */
|
||||
DBG("GOT DCD DROP\n");
|
||||
close(tty->fds[FD_MASTER].fd);
|
||||
tty->fds[FD_MASTER].fd = -1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void *_read_net(void *arg)
|
||||
{
|
||||
ttynvt_t *tty = (ttynvt_t *) arg;
|
||||
@@ -280,6 +297,8 @@ static void *_read_net(void *arg)
|
||||
}
|
||||
tty->net_cnt = 0;
|
||||
}
|
||||
if (_net_read_check_exit(tty))
|
||||
break;
|
||||
}
|
||||
|
||||
if (tty->fds[FD_MASTER].revents & POLLIN)
|
||||
@@ -419,6 +438,7 @@ static void _modem_status_cb(void *cctx, int status)
|
||||
mcr |= TIOCM_DSR;
|
||||
|
||||
pthread_mutex_lock(&tty->tty_lock);
|
||||
tty->smcr_last = tty->smcr;
|
||||
tty->smcr = mcr;
|
||||
pthread_mutex_unlock(&tty->tty_lock);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user