touchups and consistency (making sure to make it true elsewhere
authorMike Karels <karels@ucbvax.Berkeley.EDU>
Wed, 5 Feb 1986 09:30:24 +0000 (01:30 -0800)
committerMike Karels <karels@ucbvax.Berkeley.EDU>
Wed, 5 Feb 1986 09:30:24 +0000 (01:30 -0800)
before checking this in)

SCCS-vsn: lib/libc/sys/select.2 6.4

usr/src/lib/libc/sys/select.2

index 82499cd..a24ce3e 100644 (file)
@@ -2,12 +2,12 @@
 .\" All rights reserved.  The Berkeley software License Agreement
 .\" specifies the terms and conditions for redistribution.
 .\"
 .\" All rights reserved.  The Berkeley software License Agreement
 .\" specifies the terms and conditions for redistribution.
 .\"
-.\"    @(#)select.2    6.3 (Berkeley) %G%
+.\"    @(#)select.2    6.4 (Berkeley) %G%
 .\"
 .TH SELECT 2 ""
 .UC 5
 .SH NAME
 .\"
 .TH SELECT 2 ""
 .UC 5
 .SH NAME
-select \- synchronous i/o multiplexing
+select \- synchronous I/O multiplexing
 .SH SYNOPSIS
 .nf
 .ft B
 .SH SYNOPSIS
 .nf
 .ft B
@@ -21,16 +21,16 @@ fd_set *readfds, *writefds, *exceptfds;
 struct timeval *timeout;
 .PP
 .ft B
 struct timeval *timeout;
 .PP
 .ft B
-int fd;
-fd_set fdset;
 FD_SET(fd, &fdset)     
 FD_CLR(fd, &fdset)     
 FD_ISSET(fd, &fdset)   
 FD_ZERO(&fdset)        
 FD_SET(fd, &fdset)     
 FD_CLR(fd, &fdset)     
 FD_ISSET(fd, &fdset)   
 FD_ZERO(&fdset)        
+int fd;
+fd_set fdset;
 .fi
 .SH DESCRIPTION
 .I Select
 .fi
 .SH DESCRIPTION
 .I Select
-examines the i/o descriptor sets whose addresses are passed in
+examines the I/O descriptor sets whose addresses are passed in
 .IR readfds ,
 .IR writefds ,
 and
 .IR readfds ,
 .IR writefds ,
 and
@@ -47,11 +47,13 @@ in the descriptor sets are examined.
 On return,
 .I select
 replaces the given descriptor sets
 On return,
 .I select
 replaces the given descriptor sets
-with subsets consisting of those descriptors that are ready.
+with subsets consisting of those descriptors that are ready
+for the requested operation.
 The total number of ready descriptors in all the sets is returned in
 .IR nfound .
 .PP
 The total number of ready descriptors in all the sets is returned in
 .IR nfound .
 .PP
-Some macros are provided for manipulating descriptor sets.
+The descriptor sets are stored as bit fields in arrays of integers.
+The following macros are provided for manipulating such descriptor sets:
 .I "FD_ZERO(&fdset)"
 initializes a descriptor set
 .I fdset
 .I "FD_ZERO(&fdset)"
 initializes a descriptor set
 .I fdset
@@ -85,7 +87,7 @@ selection to complete.  If
 .I timeout
 is a zero pointer, the select blocks indefinitely.  To affect a poll, the
 .I timeout
 .I timeout
 is a zero pointer, the select blocks indefinitely.  To affect a poll, the
 .I timeout
-argument should be non-zero, pointing to a zero valued timeval structure.
+argument should be non-zero, pointing to a zero-valued timeval structure.
 .PP
 Any of
 .IR readfds ,
 .PP
 Any of
 .IR readfds ,
@@ -101,6 +103,11 @@ or \-1 if an error occurred.
 If the time limit expires then
 .I select
 returns 0.
 If the time limit expires then
 .I select
 returns 0.
+If
+.I select
+returns with an error,
+including one due to an interrupted call,
+the descriptor sets will be unmodified.
 .SH "ERRORS
 An error return from \fIselect\fP indicates:
 .TP 15
 .SH "ERRORS
 An error return from \fIselect\fP indicates:
 .TP 15
@@ -117,5 +124,23 @@ negative or too large.
 .SH SEE ALSO
 accept(2), connect(2), read(2), write(2), recv(2), send(2), getdtablesize(2)
 .SH BUGS
 .SH SEE ALSO
 accept(2), connect(2), read(2), write(2), recv(2), send(2), getdtablesize(2)
 .SH BUGS
-The descriptor sets are always modified on return, even
-if the call returns as the result of the timeout.
+Although the provision of
+.IR getdtablesize (2)
+was intended to allow user programs to be written independent
+of the kernel limit on the number of open files, the dimension
+of a sufficiently large bit field for select remains a problem.
+The default size FD_SETSIZE (currently 256) is somewhat larger than
+the current kernel limit to the number of open files.
+However, in order to accomodate programs which might potentially
+use a larger number of open files with select, it is possible
+to increase this size within a program by providing
+a larger definition of FD_SETSIZE before the inclusion of <sys/types.h>.
+.PP
+.I Select
+should probably return the time remaining from the original timeout,
+if any, by modifying the time value in place.
+This may be implemented in future versions of the system.
+Thus, it is unwise to assume that the timeout value will be unmodified
+by the
+.I select
+call.