diff --git a/bin/stty/extern.h b/bin/stty/extern.h --- a/bin/stty/extern.h +++ b/bin/stty/extern.h @@ -36,7 +36,7 @@ int ksearch(char ***, struct info *); int msearch(char ***, struct info *); void optlist(void); -void print(struct termios *, struct winsize *, int, enum FMT); +void print(struct termios *, struct winsize *, int, int, enum FMT); void usage(void) __dead2; extern struct cchar cchars1[], cchars2[]; diff --git a/bin/stty/key.c b/bin/stty/key.c --- a/bin/stty/key.c +++ b/bin/stty/key.c @@ -125,7 +125,7 @@ void f_all(struct info *ip) { - print(&ip->t, &ip->win, ip->ldisc, BSD); + print(&ip->t, &ip->win, ip->ldisc, ip->drainwait, BSD); } void @@ -177,7 +177,7 @@ f_everything(struct info *ip) { - print(&ip->t, &ip->win, ip->ldisc, BSD); + print(&ip->t, &ip->win, ip->ldisc, ip->drainwait, BSD); } void diff --git a/bin/stty/print.c b/bin/stty/print.c --- a/bin/stty/print.c +++ b/bin/stty/print.c @@ -41,7 +41,8 @@ static const char *ccval(struct cchar *, int); void -print(struct termios *tp, struct winsize *wp, int ldisc, enum FMT fmt) +print(struct termios *tp, struct winsize *wp, int ldisc, int drainwait, + enum FMT fmt) { struct cchar *p; long tmp; @@ -76,6 +77,8 @@ cnt += printf("speed %d baud;", ispeed); if (fmt >= BSD) cnt += printf(" %d rows; %d columns;", wp->ws_row, wp->ws_col); + if (drainwait >= 0 && fmt >= BSD) + cnt += printf(" drainwait %d;", drainwait); if (cnt) (void)printf("\n"); diff --git a/bin/stty/stty.h b/bin/stty/stty.h --- a/bin/stty/stty.h +++ b/bin/stty/stty.h @@ -36,6 +36,7 @@ int off; /* turn off */ int set; /* need set */ int wset; /* need window set */ + int drainwait; /* drainwait */ const char *arg; /* argument */ struct termios t; /* terminal info */ struct winsize win; /* window info */ diff --git a/bin/stty/stty.c b/bin/stty/stty.c --- a/bin/stty/stty.c +++ b/bin/stty/stty.c @@ -86,6 +86,10 @@ err(1, "TIOCGETD"); if (ioctl(i.fd, TIOCGWINSZ, &i.win) < 0) warn("TIOCGWINSZ"); + if (ioctl(i.fd, TIOCGDRAINWAIT, &i.drainwait) < 0) { + warn("TIOCGDRAINWAIT"); + i.drainwait = -1; + } checkredirect(); /* conversion aid */ @@ -96,7 +100,7 @@ /* FALLTHROUGH */ case BSD: case POSIX: - print(&i.t, &i.win, i.ldisc, fmt); + print(&i.t, &i.win, i.ldisc, i.drainwait, fmt); break; case GFLAG: gprint(&i.t, &i.win, i.ldisc);