pipe_select

Determines which pipes are ready for reading or writing.

Library:LibC
Classification:Other
Service:File and Directory I/O

Syntax

  #include <sys/select.h> 
   
  int pipe_select (
     int                     nfds,
     fd_set                 *readfds,
     fd_set                 *writefds,
     fd_set                 *exceptfds,
     const struct timeval   *timeout);
  

Parameters

nfds

(IN) Specifies the total number of file handles to examine. Set this parameter to 0 because it is not used. The fd_count field in the fd_set structure is used instead.

readfds

(IN/OUT) Points, on input, to the file descriptors to check for being ready to read. On output, indicates which file descriptors are ready to read. If set to NULL, file descriptors are not checked for read operations.

writefds

(IN/OUT) Points, on input, to the file descriptors to check for being ready to write. On output, indicates which file descriptors are ready to write. If set to NULL, file descriptors are not checked for write operations.

exceptfds

(IN/OUT) Points, on input, to the file descriptors to check for pending error conditions. On output, indicates which file descriptors have pending error conditions. If set to NULL, file descriptors are not checked for error conditions.

timeout

(IN) Points to the timeval structure containing the maximum time to wait. If set to NULL, pipe_select blocks indefinitely until at least one descriptor meets the operation criteria.

Return Values

If successful, returns the number of ready handles contained in the handle sets. Otherwise, returns -1 and sets errno to one of the following:

Decimal

Constant

Description

4

EBADF

One of the handle sets specified an invalid handle.

9

EINVAL

The readfds, writefds, and exceptfds parameters do not point to unique structures. One or more point to the same structure.

63

ENITR

The function was interrupted.

105

ENOCONTEXT

The calling thread has no context.

Remarks

The pipe_select function only works with pipes.

NOTE:For sockets, use the select function.

Each of the parameters that points to an fd_set structure must point to a unique structure. You cannot use the same structure to check for multiple conditions.

For more information about the fd_set structure and the macros used for configuration, see fd_set in Volume 2.

The pipe_select function examines the file handle sets to see if any of the handles are ready for reading, are ready for writing, or have an exception condition pending. It replaces the given file handle sets with subsets consisting of those handles that are ready for the operation. The pipe_select function does not use the nfds parameter to determine how many handles to examine in a set. Instead, it uses the fd_count parameter in the fd_set structure.

If timeout is a NULL pointer, pipe_select blocks indefinitely. To poll, timeout can point to a zero-valued timeval structure.

See Also