summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2016-01-26 07:57:44 +0000
committerkib <kib@FreeBSD.org>2016-01-26 07:57:44 +0000
commitd4a0747609e71f3bc4a94b77f5b61444581f805a (patch)
tree371048f311ba08e6b9018e3e6d38cda91c1f9e5d /lib/libc
parent3715af248f8b9c60933bd1211bc486f4cfe90867 (diff)
downloadFreeBSD-src-d4a0747609e71f3bc4a94b77f5b61444581f805a.zip
FreeBSD-src-d4a0747609e71f3bc4a94b77f5b61444581f805a.tar.gz
Restore flushing of output for revoke(2) again. Document revoke()'s
intended behaviour in its man page. Simplify tty_drain() to match. Don't call ttydevsw methods in tty_flush() if the device is gone since we now sometimes call it then. The flushing was supposed to be implemented by passing the FNONBLOCK flag to VOP_CLOSE() for revoke(). The tty driver is one of the few that can block in close and was one of the fewer that knew about this. This almost worked in FreeBSD-1 and similarly in Net/2. These versions only almost worked because there was and is considerable confusion between IO_NDELAY and FNONBLOCK (aka O_NONBLOCK). IO_NDELAY is only valid for VOP_READ() and VOP_WRITE(). For other VOPs it has the same value as O_SHLOCK. But since vfs_subr.c and tty.c consistently used the wrong flag and the O_SHLOCK flag is rarely set, this mostly worked. It also gave the feature than applications could get the non-blocking close by abusing O_SHLOCK. This was first broken then fixed in 1995. I changed only the tty driver to use FNONBLOCK, as a hack to get non-blocking via the normal flag FNONBLOCK for last closes. I didn't know about revoke()'s use of IO_NDELAY or change it to be consistent, so revoke() was broken. Then I changed revoke() to match. This was next broken in 1997 then fixed in 1998. Importing Lite2 made the flags inconsistent again by undoing the fix only in vfs_subr.c. This was next broken in 2008 by replacing everything in tty.c and not checking any flags in last close. Other bugs in draining limited the resulting unbounded waits to drain in some cases. It is now possible to fix this better using the new FREVOKE flag. Just restore flushing for revoke() for now. Don't restore or undo any hacks for ordinary last closes yet. But remove dead code in the 1-second relative timeout (r272789). This did extra work to extend the buggy draining for revoke() for as long as possible. The 1-second timeout made this not very long by usually flushing after 1 second. Submitted by: bde MFC after: 2 weeks
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/sys/revoke.28
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/libc/sys/revoke.2 b/lib/libc/sys/revoke.2
index 482cbf6..3d7ad00 100644
--- a/lib/libc/sys/revoke.2
+++ b/lib/libc/sys/revoke.2
@@ -31,7 +31,7 @@
.\" @(#)revoke.2 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd June 4, 1993
+.Dd Jan 25, 2016
.Dt REVOKE 2
.Os
.Sh NAME
@@ -59,7 +59,8 @@ and a
system call will succeed.
If the file is a special file for a device which is open,
the device close function
-is called as if all open references to the file had been closed.
+is called as if all open references to the file had been closed
+using a special close method which does not block.
.Pp
Access to a file may be revoked only by its owner or the super user.
The
@@ -104,3 +105,6 @@ The
.Fn revoke
system call first appeared in
.Bx 4.3 Reno .
+.Sh BUGS
+The non-blocking close method is only correctly implemented for
+terminal devices.
OpenPOWER on IntegriCloud