aboutsummaryrefslogtreecommitdiff
path: root/share/man/man4/tty.4
diff options
context:
space:
mode:
authorIan Lepore <ian@FreeBSD.org>2017-01-12 00:48:06 +0000
committerIan Lepore <ian@FreeBSD.org>2017-01-12 00:48:06 +0000
commitf64342e354d95a2e5101850ad6d9199c211748ad (patch)
tree8a3eafa3ed556e322c5c36881e108b6284db5e06 /share/man/man4/tty.4
parentca7d74d4675911e8518a0cbf2f06b3de8158b383 (diff)
downloadsrc-f64342e354d95a2e5101850ad6d9199c211748ad.tar.gz
src-f64342e354d95a2e5101850ad6d9199c211748ad.zip
Rework tty_drain() to poll the hardware for completion, and restore
drain timeout handling to historical freebsd behavior. The primary reason for these changes is the need to have tty_drain() call ttydevsw_busy() at some reasonable sub-second rate, to poll hardware that doesn't signal an interrupt when the transmit shift register becomes empty (which includes virtually all USB serial hardware). Such hardware hangs in a ttyout wait, because it never gets an opportunity to trigger a wakeup from the sleep in tty_drain() by calling ttydisc_getc() again, after handing the last of the buffered data to the hardware. While researching the history of changes to tty_drain() I stumbled across some email describing the historical BSD behavior of tcdrain() and close() on serial ports, and the ability of comcontrol(1) to control timeout behavior. Using that and some advice from Bruce Evans as a guide, I've put together these changes to implement the hardware polling and restore the historical timeout behaviors... - tty_drain() now calls ttydevsw_busy() in a loop at 10 Hz to accomodate hardware that requires polling for busy state. - The "new historical" behavior for draining during close(2) is retained: the drain timeout is "1 second without making any progress". When the 1-second timeout expires, if the count of bytes remaining in the tty layer buffer is smaller than last time, the timeout is extended for another second. Unfortunately, the same logic cannot be extended all the way down to the hardware, because the interface to that layer is a simple busy/not-busy indication. - Due to the previous point, an application that needs a guarantee that all data has been transmitted must use TIOCDRAIN/tcdrain(3) before calling close(2). - The historical behavior of honoring the drainwait setting for TIOCDRAIN (used by tcdrain(3)) is restored. - The historical kern.drainwait sysctl to control the global default drainwait time is restored, but is now named kern.tty_drainwait. - The historical default drainwait timeout of 300 seconds is restored. - Handling of TIOCGDRAINWAIT and TIOCSDRAINWAIT ioctls is restored (this also makes the comcontrol(1) drainwait verb work again). - Manpages are updated to document these behaviors. Reviewed by: bde (prior version)
Notes
Notes: svn path=/head/; revision=311954
Diffstat (limited to 'share/man/man4/tty.4')
-rw-r--r--share/man/man4/tty.413
1 files changed, 11 insertions, 2 deletions
diff --git a/share/man/man4/tty.4 b/share/man/man4/tty.4
index ec6d9f155aca..ef5bed8be554 100644
--- a/share/man/man4/tty.4
+++ b/share/man/man4/tty.4
@@ -28,7 +28,7 @@
.\" @(#)tty.4 8.3 (Berkeley) 4/19/94
.\" $FreeBSD$
.\"
-.Dd December 26, 2009
+.Dd January 11, 2017
.Dt TTY 4
.Os
.Sh NAME
@@ -238,7 +238,16 @@ Start output on the terminal (like typing ^Q at the keyboard).
Make the terminal the controlling terminal for the process (the process
must not currently have a controlling terminal).
.It Dv TIOCDRAIN Fa void
-Wait until all output is drained.
+Wait until all output is drained, or until the drain wait timeout expires.
+.It Dv TIOCGDRAINWAIT Fa int *timeout
+Return the current drain wait timeout in seconds.
+.It Dv TIOCSDRAINWAIT Fa int *timeout
+Set the drain wait timeout in seconds.
+A value of zero disables timeouts.
+The default drain wait timeout is controlled by the tunable
+.Xr sysctl 8
+OID
+.Va kern.tty_drainwait .
.It Dv TIOCEXCL Fa void
Set exclusive use on the terminal.
No further opens are permitted except by root.