Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ select(2) — HP-UX 5.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

fcntl(2)

read(2)

write(2)

SELECT(2)

NAME

select − synchronous I/O multiplexing

SYNOPSIS

#include <time.h>

int select(nfds, readfds, writefds, exceptfds, timeout)
int nfds, *readfds, *writefds, *exceptfds;
struct timeval *timeout;

HP-UX COMPATIBILITY

Level: HP-UX/STANDARD - Real Time

Origin: HP and UCB

DESCRIPTION

Select examines the file descriptors specified by the bit masks readfds, writefds and exceptfds. The bits from 0 through nfds-1 are examined. File descriptor f is represented by the bit “1<<f” in the masks.  More formally, a file descriptor is represented by:

fds[(f / BITS_PER_INT)] & (1 << (f % BITS_PER_INT))

When select completes successfully it returns the three bit masks modified as follows: For each file descriptor less than nfds, the corresponding bit in each mask is set if the bit was set upon entry and certain conditions prevail.  The bit is set if the file descriptor is ready for reading, writing or has an exceptional condition pending. 

If timeout is a non-zero pointer, it specifies a maximum interval to wait for the selection to complete.  If timeout is a zero pointer, the select waits until an event causes one of the masks to be returned with a valid (non-zero) value.  To poll, the timeout argument should be non-zero, pointing to a zero valued timeval structure.  Specific implementations may place limitations on the maximum timeout interval supported.  The constant MAX_ALARM defined in <sys/param.h> specifies the implementation-specific maximum (in seconds).  Whenever timeout specifies a value greater than this maximum, it is silently rounded down to this maximum.  On all implementations, MAX_ALARM is guaranteed to be at least 31 days (in seconds).  Note that the use of a timeout does not affect any pending timers set up by alarm(2) or setitimer(2). 

Any or all of readfds, writefds, and exceptfds may be given as 0 if no descriptors are of interest. 

ERRORS

An error return from select indicates:

[EBADF] One or more of the bit masks specified an invalid descriptor. 

[EINTR] A signal was delivered before any of the selected for events occurred or before the time limit expired. 

[EFAULT] One or more of the pointers was invalid. 

[EINVAL] The timeout value specified a time outside of the acceptable range. 

RETURN VALUE

Select returns the number of descriptors contained in the bit masks, or −1 if an error occurred.  If the time limit expires then select returns 0 and all the masks are cleared. 

HARDWARE DEPENDENCIES

Series 500:
Select(2) supports the following devices and file types:

 pipes
fifo special files (named pipes)
Model 520 Internal Terminal Emulator (ITE)
HP 98700H ITE and HP-HIL input devices
         (such as HP 46020A Keyboard and HP 46086A Button Box)
HP 27128A ASI tty driver
HP 27140A Modem MUX tty driver
pty(4) special files
HP 27125A LAN interface card driver (LLA)
HP 27130A/B port MUX (with appropriate firmware revision)
 

Ordinary files always select true whenever selecting on reads, writes, and/or exceptions. 

The convention for device files that do not support select(2) is to always return true for those conditions the user is selecting on.

Series 200:
Select(2) supports the following devices and file types:

 pipes
fifo special files (named pipes)
Model 520 Internal Terminal Emulator (ITE)
HP 98643 LAN interface card driver
All serial interfaces
pty(4) special files
All ITEs and HP-HIL input devices
 

Ordinary files always select true whenever selecting on reads, writes, and/or exceptions. 

File types not supporting select(2) always return true.

SEE ALSO

fcntl(2), read(2), write(2). 

Hewlett-Packard  —  last mod. May 11, 2021

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026