mirror of https://github.com/mkerrisk/man-pages
select_tut.2: DESCRIPTION: defer to select(2)
Avoid duplicating the same information in two pages. Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
parent
b3b45b2b16
commit
c9a275a703
|
@ -31,8 +31,7 @@
|
|||
.\"
|
||||
.TH SELECT_TUT 2 2019-03-06 "Linux" "Linux Programmer's Manual"
|
||||
.SH NAME
|
||||
select, pselect, FD_CLR, FD_ISSET, FD_SET, FD_ZERO \-
|
||||
synchronous I/O multiplexing
|
||||
select, pselect \- synchronous I/O multiplexing
|
||||
.SH SYNOPSIS
|
||||
.PP
|
||||
See
|
||||
|
@ -46,135 +45,16 @@ to see if any of them is, or becomes, "ready";
|
|||
that is, to see whether I/O becomes possible,
|
||||
or an "exceptional condition" has occurred on any of the file descriptors.
|
||||
.PP
|
||||
Its principal arguments are three "sets" of file descriptors:
|
||||
\fIreadfds\fP, \fIwritefds\fP, and \fIexceptfds\fP.
|
||||
Each set is declared as type
|
||||
.IR fd_set ,
|
||||
and its contents can be manipulated with the macros
|
||||
.BR FD_CLR (),
|
||||
.BR FD_ISSET (),
|
||||
.BR FD_SET (),
|
||||
This page provides background and tutorial information
|
||||
on the use of these system calls.
|
||||
For details of the arguments and semantics of
|
||||
.BR select ()
|
||||
and
|
||||
.BR FD_ZERO ().
|
||||
A newly declared set should first be cleared using
|
||||
.BR FD_ZERO ().
|
||||
.BR select ()
|
||||
modifies the contents of the sets according to the rules
|
||||
described below; after calling
|
||||
.BR select ()
|
||||
you can test if a file descriptor is still present in a set with the
|
||||
.BR FD_ISSET ()
|
||||
macro.
|
||||
.BR FD_ISSET ()
|
||||
returns nonzero if a specified file descriptor is present in a set
|
||||
and zero if it is not.
|
||||
.BR FD_CLR ()
|
||||
removes a file descriptor from a set.
|
||||
.SS Arguments
|
||||
.TP
|
||||
\fIreadfds\fP
|
||||
This set is watched to see if data is available for reading from any of
|
||||
its file descriptors.
|
||||
After
|
||||
.BR select ()
|
||||
has returned, \fIreadfds\fP will be
|
||||
cleared of all file descriptors except for those that
|
||||
are immediately available for reading.
|
||||
.TP
|
||||
\fIwritefds\fP
|
||||
This set is watched to see if there is space to write data to any of
|
||||
its file descriptors.
|
||||
After
|
||||
.BR select ()
|
||||
has returned, \fIwritefds\fP will be
|
||||
cleared of all file descriptors except for those that
|
||||
are immediately available for writing.
|
||||
.TP
|
||||
\fIexceptfds\fP
|
||||
This set is watched for "exceptional conditions".
|
||||
In practice, only one such exceptional condition is common:
|
||||
the availability of \fIout-of-band\fP (OOB) data for reading
|
||||
from a TCP socket.
|
||||
See
|
||||
.BR recv (2),
|
||||
.BR send (2),
|
||||
and
|
||||
.BR tcp (7)
|
||||
for more details about OOB data.
|
||||
(One other less common case where
|
||||
.BR select (2)
|
||||
indicates an exceptional condition occurs with pseudoterminals
|
||||
in packet mode; see
|
||||
.BR ioctl_tty (2).)
|
||||
After
|
||||
.BR select ()
|
||||
has returned,
|
||||
\fIexceptfds\fP will be cleared of all file descriptors except for those
|
||||
for which an exceptional condition has occurred.
|
||||
.TP
|
||||
\fInfds\fP
|
||||
This is an integer one more than the maximum of any file descriptor in
|
||||
any of the sets.
|
||||
In other words, while adding file descriptors to each of the sets,
|
||||
you must calculate the maximum integer value of all of them,
|
||||
then increment this value by one, and then pass this as \fInfds\fP.
|
||||
.TP
|
||||
\fIutimeout\fP
|
||||
This is the longest time
|
||||
.BR select ()
|
||||
may wait before returning, even if nothing interesting happened.
|
||||
If this value is passed as NULL, then
|
||||
.BR select ()
|
||||
blocks indefinitely waiting for a file descriptor to become ready.
|
||||
\fIutimeout\fP can be set to zero seconds, which causes
|
||||
.BR select ()
|
||||
to return immediately, with information about the readiness
|
||||
of file descriptors at the time of the call.
|
||||
The structure \fIstruct timeval\fP is defined as:
|
||||
.IP
|
||||
.in +4n
|
||||
.EX
|
||||
struct timeval {
|
||||
time_t tv_sec; /* seconds */
|
||||
long tv_usec; /* microseconds */
|
||||
};
|
||||
.EE
|
||||
.in
|
||||
.TP
|
||||
\fIntimeout\fP
|
||||
This argument for
|
||||
.BR pselect ()
|
||||
has the same meaning as
|
||||
.IR utimeout ,
|
||||
but
|
||||
.I "struct timespec"
|
||||
has nanosecond precision as follows:
|
||||
.IP
|
||||
.in +4n
|
||||
.EX
|
||||
struct timespec {
|
||||
long tv_sec; /* seconds */
|
||||
long tv_nsec; /* nanoseconds */
|
||||
};
|
||||
.EE
|
||||
.in
|
||||
.TP
|
||||
\fIsigmask\fP
|
||||
This argument holds a set of signals that the kernel should unblock
|
||||
(i.e., remove from the signal mask of the calling thread),
|
||||
while the caller is blocked inside the
|
||||
.BR pselect ()
|
||||
call (see
|
||||
.BR sigaddset (3)
|
||||
and
|
||||
.BR sigprocmask (2)).
|
||||
It may be NULL,
|
||||
in which case the call does not modify the signal mask on
|
||||
entry and exit to the function.
|
||||
In this case,
|
||||
.BR pselect ()
|
||||
will then behave just like
|
||||
.BR select ().
|
||||
.BR pselect (),
|
||||
see
|
||||
.BR select (2).
|
||||
.PP
|
||||
.\"
|
||||
.SS Combining signal and data events
|
||||
.BR pselect ()
|
||||
is useful if you are waiting for a signal as well as
|
||||
|
|
Loading…
Reference in New Issue