From f5775252097952f6264066a0305b1a70e4169a2a Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Wed, 28 Apr 1999 02:46:44 +0000 Subject: [PATCH] try harder to flush the tty output buffer in disestablish_ppp --- pppd/sys-linux.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/pppd/sys-linux.c b/pppd/sys-linux.c index c63ac9a..70ba2fa 100644 --- a/pppd/sys-linux.c +++ b/pppd/sys-linux.c @@ -381,14 +381,23 @@ int establish_ppp (int tty_fd) void disestablish_ppp(int tty_fd) { + int nout; + + if (!hungup) { /* - * Attempt to restore the previous tty settings + * Flush the tty output buffer so that the TIOCSETD doesn't hang. + * We may have to do this several times because the tcflush only + * affects the serial driver, and may trigger the ppp driver to + * supply more data to the serial driver. */ - if (!hungup) { + do { + if (tcflush(tty_fd, TCIOFLUSH) < 0) + break; + nout = 0; + } while (ioctl(tty_fd, TIOCOUTQ, &nout) >= 0 && nout > 0); /* * Restore the previous line discipline */ - tcflush(tty_fd, TCIOFLUSH); if (ioctl(tty_fd, TIOCSETD, &tty_disc) < 0) { if ( ! ok_error (errno)) error("ioctl(TIOCSETD, N_TTY): %m"); -- 2.39.2