HP-UX Reference (11i v3 07/02) - 2 System Calls (vol 5)
s
select(2) select(2)
ttymask[i] = MASK(tty[i]);
readmask.fds_bits[k] |= ttymask[i];
}
timeout.tv_sec = 5;
timeout.tv_usec = 0;
for (k=0; k < NWORDS; k++)
readfds.fds_bits[k] = readmask.fds_bits[k];
/* select on NTTYS+3 file descriptors if stdin, stdout
* and stderr are also open
*/
if ((nfound = select (NTTYS+3, &readfds, 0, 0, &timeout)) == -1)
perror ("select failed");
else if (nfound == 0)
printf ("select timed out \n");
else for (i=0, k=0; i < NTTYS && k < NWORDS; k++)
for (j=0; j < NFDBITS && i < NTTYS; j++, i++)
if (ttymask[i] & readfds.fds_bits[k])
/* Read from tty[i]. The code for reading
* is not shown here.
*/
else printf ("tty[%d] is not ready for reading \n",i);
WARNINGS
The file descriptor masks are always modified on return, even if the call returns as the result of a timeout.
DEPENDENCIES
select() supports the following devices and file types:
• pipes
• fifo special files (named pipes)
• all serial devices
• All ITEs (internal terminal emulators) and HP-HIL input devices
• lan(7) special files
• pty(7) special files
• sockets
AUTHOR
select() was developed by HP and the University of California, Berkeley.
SEE ALSO
fcntl(2), poll(2), read(2), sigprocmask(2), write(2), thread_safety(5),
<sys/time.h> .
358 Hewlett-Packard Company − 5 − HP-UX 11i Version 3: February 2007