diff options
author | ian <ian@FreeBSD.org> | 2017-03-02 04:23:53 +0000 |
---|---|---|
committer | ian <ian@FreeBSD.org> | 2017-03-02 04:23:53 +0000 |
commit | 441c0c0ed529fc9fb17e0feb520d123e21acb7f5 (patch) | |
tree | 798f99c36b3f220290c85d5b78d50866d47b5875 /share/man/man4 | |
parent | a8e4be5c56fa510af7512ec8fc2bfe5dc41ffe45 (diff) | |
download | FreeBSD-src-441c0c0ed529fc9fb17e0feb520d123e21acb7f5.zip FreeBSD-src-441c0c0ed529fc9fb17e0feb520d123e21acb7f5.tar.gz |
MFC r311954, r311996, r312077, r312080:
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.
Restructure the tty_drain loop so that device-busy is checked one more time
after tty_timedwait() returns an error only if the error is EWOULDBLOCK;
other errors cause an immediate return. This fixes the case of the tty
disappearing while in tty_drain().
Check tty_gone() after allocating IO buffers. The tty lock has to be
dropped then reacquired due to using M_WAITOK, which opens a window in
which the tty device can disappear. Check for this and return ENXIO
back up the call chain so that callers can cope.
Correct the comments about how much buffer is allocated.
Diffstat (limited to 'share/man/man4')
-rw-r--r-- | share/man/man4/tty.4 | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/share/man/man4/tty.4 b/share/man/man4/tty.4 index ec6d9f1..ef5bed8 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. |