Allows a program to monitor multiple file descriptors, waiting until one or more of the file descriptors become "ready" for some class of I/O operation. A file descriptor is considered ready if it is possible to perform the corresponding I/O operation (e.g., sys_read) without blocking.
Arguments
eax |
82 |
ebx |
The highest-numbered file descriptor in any of the three sets (see below), plus 1. |
ecx |
Pointer to a fd_set structure which specifies the first independent set of file descriptors to be watched for becoming available for reading (more precisely, to see if a read will not block; in particular, a file descriptor is also ready on end-of-file). On exit, the set is modified in place to indicate which file descriptors actually changed status.
fd_set defined as follows:
struc fd_set
{
.fds_bits rd 32
} |
ecx may be specified as NULL if no file descriptors are to be watched for the this class of events. |
edx |
Pointer to a fd_set structure which specifies second independent set of file descriptors to be watched to see if a write will not block. On exit, the set is modified in place to indicate which file descriptors actually changed status.
edx may be specified as NULL if no file descriptors are to be watched for the this class of events. |
esi |
Pointer to a fd_set structure which specifies third independent set of file descriptors to be watched for exceptions. On exit, the set is modified in place to indicate which file descriptors actually changed status.
esi may be specified as NULL if no file descriptors are to be watched for the this class of events. |
edi |
Pointer to a timeval structure specifying the upper bound on the amount of time elapsed before sys_select returns. Upper bound may be zero, causing sys_select to return immediately. (This is useful for polling.) If edi is NULL (no timeout), sys_select can block indefinitely.
On exit timeval is modified to reflect the amount of time not slept.
timeval defined as follows:
struc timeval
{
.tv_sec rd 1
.tv_usec rd 1
} |
|
Return values
If the system call succeeds the return value is the number of file descriptors contained in the three returned descriptor sets (that is, the total number of bits that are set in all three sets) which may be zero if the timeout expires before anything interesting happens.
If the system call fails the return value is one of the following errno values:
-EBADF |
An invalid file descriptor was given in one of the sets. (Perhaps a file descriptor that was already closed, or one on which an error has occurred.) |
-EINTR |
A signal was caught. |
-EINVAL |
ebx is negative or the value contained within edi is invalid. |
-ENOMEM |
Unable to allocate memory for internal tables. |
|
Remarks
sys_select may report a socket file descriptor as "ready for reading", while nevertheless a subsequent read blocks. This could for example happen when data has arrived but upon examination has wrong checksum and is discarded. There may be other circumstances in which a file descriptor is spuriously reported as ready. Thus it may be safer to use O_NONBLOCK on sockets that should not block.
Compatibility
n/a |