BSD 4_4_Lite2 release
[unix-history] / usr / src / share / doc / psd / 05.sysman / 1.5.t
index 4e7efb4..d125ce7 100644 (file)
@@ -1,24 +1,50 @@
 .\" Copyright (c) 1983, 1993, 1994
 .\"    The Regents of the University of California.  All rights reserved.
 .\"
 .\" Copyright (c) 1983, 1993, 1994
 .\"    The Regents of the University of California.  All rights reserved.
 .\"
-.\" %sccs.include.redist.roff%
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\"    must display the following acknowledgement:
+.\"    This product includes software developed by the University of
+.\"    California, Berkeley and its contributors.
+.\" 4. Neither the name of the University nor the names of its contributors
+.\"    may be used to endorse or promote products derived from this software
+.\"    without specific prior written permission.
 .\"
 .\"
-.\"    @(#)1.5.t       8.3 (Berkeley) %G%
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\"    @(#)1.5.t       8.6 (Berkeley) 5/29/94
 .\"
 .Sh 2 Descriptors
 .Sh 3 "The reference table
 .PP
 Each process has access to resources through
 \fIdescriptors\fP.  Each descriptor is a handle allowing
 .\"
 .Sh 2 Descriptors
 .Sh 3 "The reference table
 .PP
 Each process has access to resources through
 \fIdescriptors\fP.  Each descriptor is a handle allowing
-the process to reference objects such as files, devices
+processes to reference objects such as files, devices
 and communications links.
 .PP
 Rather than allowing processes direct access to descriptors, the system
 introduces a level of indirection, so that descriptors may be shared
 between processes.  Each process has a \fIdescriptor reference table\fP,
 and communications links.
 .PP
 Rather than allowing processes direct access to descriptors, the system
 introduces a level of indirection, so that descriptors may be shared
 between processes.  Each process has a \fIdescriptor reference table\fP,
-containing pointers to the actual descriptors.  The descriptors
-themselves thus have multiple references, and are reference counted by the
-system.
+containing pointers to the actual descriptors.
+The descriptors themselves therefore may have multiple references,
+and are reference counted by the system.
 .PP
 Each process has a limited size descriptor reference table, where
 the current size is returned by the
 .PP
 Each process has a limited size descriptor reference table, where
 the current size is returned by the
@@ -29,12 +55,12 @@ call:
 nds = getdtablesize();
 result int nds;
 .DE
 nds = getdtablesize();
 result int nds;
 .DE
-and guaranteed to be at least 20.
+and guaranteed to be at least 64.
 The maximum number of descriptors is a resource limit (see section
 .Xr 1.6.3 ).
 The entries in the descriptor reference
 table are referred to by small integers; for example if there
 The maximum number of descriptors is a resource limit (see section
 .Xr 1.6.3 ).
 The entries in the descriptor reference
 table are referred to by small integers; for example if there
-are 20 slots they are numbered 0 to 19.
+are 64 slots they are numbered 0 to 63.
 .Sh 3 "Descriptor properties
 .PP
 Each descriptor has a logical set of properties maintained
 .Sh 3 "Descriptor properties
 .PP
 Each descriptor has a logical set of properties maintained
@@ -62,8 +88,9 @@ A duplicate of a descriptor reference may be made by doing:
 new = dup(old);
 result int new; int old;
 .DE
 new = dup(old);
 result int new; int old;
 .DE
-returning a copy of descriptor reference \fIold\fP indistinguishable from
-the original.  The \fInew\fP chosen by the system will be the
+returning a copy of descriptor reference \fIold\fP which is
+indistinguishable from the original.
+The value of \fInew\fP chosen by the system will be the
 smallest unused descriptor reference slot.
 A copy of a descriptor reference may be made in a specific slot
 by doing:
 smallest unused descriptor reference slot.
 A copy of a descriptor reference may be made in a specific slot
 by doing:
@@ -101,11 +128,12 @@ nds = select(nd, in, out, except, tvp);
 result int nds; int nd; result fd_set *in, *out, *except;
 struct timeval *tvp;
 
 result int nds; int nd; result fd_set *in, *out, *except;
 struct timeval *tvp;
 
-FD_ZERO(&fdset);
-FD_SET(fd, &fdset);
 FD_CLR(fd, &fdset);
 FD_CLR(fd, &fdset);
+FD_COPY(&fdset, &fdset2);
 FD_ISSET(fd, &fdset);
 FD_ISSET(fd, &fdset);
-int fd; fs_set fdset;
+FD_SET(fd, &fdset);
+FD_ZERO(&fdset);
+int fd; fs_set fdset, fdset2;
 .DE
 The
 .Fn select
 .DE
 The
 .Fn select
@@ -125,7 +153,9 @@ such as
 .Fn read
 or
 .Fn receive
 .Fn read
 or
 .Fn receive
-is possible, or if a connection request may be accepted (see section
+is possible, or if a connection request may be accepted (see sections
+.Xr 2.1.3
+and
 .Xr 2.3.1.4 ).
 .IP \*(bu
 A descriptor selects for output if an output oriented operation
 .Xr 2.3.1.4 ).
 .IP \*(bu
 A descriptor selects for output if an output oriented operation
@@ -135,8 +165,10 @@ or
 .Fn send
 is possible, or if an operation
 that was ``in progress'', such as connection establishment,
 .Fn send
 is possible, or if an operation
 that was ``in progress'', such as connection establishment,
-has completed (see section
-.Xr 2.1.3 ).
+has completed (see sections
+.Xr 2.1.3
+and
+.Xr 2.3.1.5 ).
 .IP \*(bu
 A descriptor selects for an exceptional condition if a condition
 that would cause a SIGURG signal to be generated exists (see section
 .IP \*(bu
 A descriptor selects for an exceptional condition if a condition
 that would cause a SIGURG signal to be generated exists (see section
@@ -144,8 +176,8 @@ that would cause a SIGURG signal to be generated exists (see section
 or other device-specific events have occurred.
 .LP
 For these tests, an operation is considered to be possible if a call
 or other device-specific events have occurred.
 .LP
 For these tests, an operation is considered to be possible if a call
-to the operation would return without blocking even if the O_NONBLOCK
-flag were clear.
+to the operation would return without blocking (even if the O_NONBLOCK
+flag were not set).
 For example, a descriptor would test as ready for reading if a read
 call would return immediately with data, an end-of-file indication,
 or an error other than EWOULDBLOCK.
 For example, a descriptor would test as ready for reading if a read
 call would return immediately with data, an end-of-file indication,
 or an error other than EWOULDBLOCK.
@@ -161,7 +193,7 @@ Options affecting I/O on a descriptor
 may be read and set by the call:
 .DS
 .Fd fcntl 3 "file control
 may be read and set by the call:
 .DS
 .Fd fcntl 3 "file control
-dopt = fcntl(d, cmd, arg)
+dopt = fcntl(d, cmd, arg);
 result int dopt; int d, cmd, arg;
 .DE
 .DS
 result int dopt; int d, cmd, arg;
 .DE
 .DS
@@ -169,14 +201,22 @@ result int dopt; int d, cmd, arg;
 l s
 l l.
 /* command values */
 l s
 l l.
 /* command values */
+
+F_DUPFD        /* return a new descriptor */
 F_GETFD        /* get file descriptor flags */
 F_SETFD        /* set file descriptor flags */
 F_GETFL        /* get file status flags */
 F_SETFL        /* set file status flags */
 F_GETOWN       /* get SIGIO/SIGURG proc/pgrp */
 F_SETOWN       /* set SIGIO/SIGURG proc/pgrp */
 F_GETFD        /* get file descriptor flags */
 F_SETFD        /* set file descriptor flags */
 F_GETFL        /* get file status flags */
 F_SETFL        /* set file status flags */
 F_GETOWN       /* get SIGIO/SIGURG proc/pgrp */
 F_SETOWN       /* set SIGIO/SIGURG proc/pgrp */
+F_GETLK        /* get blocking lock */
+F_SETLK        /* set or clear lock */
+F_SETLKW       /* set lock with wait */
 .TE
 .DE
 .TE
 .DE
+The F_DUPFD \fIcmd\fP provides identical functionality to
+.Fn dup2 ;
+it is provided solely for POSIX compatibility.
 The F_SETFD \fIcmd\fP can be used to set the close-on-exec
 flag for a file descriptor.
 The F_SETFL \fIcmd\fP may be used to set a descriptor in 
 The F_SETFD \fIcmd\fP can be used to set the close-on-exec
 flag for a file descriptor.
 The F_SETFL \fIcmd\fP may be used to set a descriptor in 
@@ -189,12 +229,11 @@ The
 system call also provides POSIX-compliant byte-range locking on files.
 However the semantics of unlocking on every 
 .Fn close
 system call also provides POSIX-compliant byte-range locking on files.
 However the semantics of unlocking on every 
 .Fn close
-rather than last close makes them almost useless.
-Much better semantics, and faster locking are provided
-by the
+rather than last close makes them useless.
+Much better semantics and faster locking are provided by the
 .Fn flock
 system call (see section
 .Fn flock
 system call (see section
-.Xr 2.2.8 ).
+.Xr 2.2.7 ).
 The
 .Fn fcntl
 and
 The
 .Fn fcntl
 and
@@ -204,7 +243,7 @@ they will serialize against each other properly.
 .PP
 Operations on non-blocking descriptors will
 either complete immediately,
 .PP
 Operations on non-blocking descriptors will
 either complete immediately,
-note an error EWOULDBLOCK,
+return the error EWOULDBLOCK,
 partially complete an input or output operation returning a partial count,
 or return an error EINPROGRESS noting that the requested operation is
 in progress.
 partially complete an input or output operation returning a partial count,
 or return an error EINPROGRESS noting that the requested operation is
 in progress.