diff --git a/bin/stty/key.c b/bin/stty/key.c --- a/bin/stty/key.c +++ b/bin/stty/key.c @@ -43,6 +43,7 @@ void f_cbreak(struct info *); void f_columns(struct info *); void f_dec(struct info *); +void f_drainwait(struct info *); void f_ek(struct info *); void f_everything(struct info *); void f_extproc(struct info *); @@ -70,6 +71,7 @@ { "columns", f_columns, F_NEEDARG }, { "cooked", f_sane, 0 }, { "dec", f_dec, 0 }, + { "drainwait", f_drainwait, F_NEEDARG }, { "ek", f_ek, 0 }, { "everything", f_everything, 0 }, { "extproc", f_extproc, F_OFFOK }, @@ -164,6 +166,18 @@ ip->set = 1; } +void +f_drainwait(struct info *ip) +{ + const char *errstr; + + ip->drainwait = strtonum(ip->arg, 0, INT_MAX, &errstr); + if (errstr != NULL) + errx(1, "drainwait: %s: %s", ip->arg, errstr); + if (ioctl(ip->fd, TIOCSDRAINWAIT, &ip->drainwait)) + err(1, "TIOCSDRAINWAIT"); +} + void f_ek(struct info *ip) { diff --git a/bin/stty/stty.1 b/bin/stty/stty.1 --- a/bin/stty/stty.1 +++ b/bin/stty/stty.1 @@ -29,7 +29,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd September 27, 2022 +.Dd September 4, 2025 .Dt STTY 1 .Os .Sh NAME @@ -490,6 +490,16 @@ is disabled, and .Dv crt is enabled.) +.It Cm drainwait Ar number +Sets the tty drainwait to +.Ar number +seconds. +The kernel default used when a tty is created can be set with the +.Xr sysctl 8 +variable +.Va kern.tty_drainwait , +which defaults to +300 seconds. .It Cm extproc Pq Fl extproc If set, this flag indicates that some amount of terminal processing is being performed by either the terminal hardware or by the remote side connected