Annotation of researchv10dc/man/adm/man2/select.2, revision 1.1

1.1     ! root        1: .TH SELECT 2
        !             2: .CT 2 file_io comm_proc
        !             3: .SH NAME
        !             4: select \(mi synchronous input/output multiplexing
        !             5: .SH SYNOPSIS
        !             6: .nf
        !             7: .B #include <sys/types.h>
        !             8: .PP
        !             9: .B int select(nfds, readfds, writefds, milli);
        !            10: .B fd_set *readfds, *writefds;
        !            11: .fi
        !            12: .SH DESCRIPTION
        !            13: .I Select
        !            14: examines a set of file descriptors
        !            15: to see if they will block if read or written.
        !            16: .I Readfds
        !            17: points to an object of type
        !            18: .BR fd_set ,
        !            19: which contains a set of descriptors to be checked for reading;
        !            20: .I writefds
        !            21: similarly for writing.
        !            22: Only descriptors
        !            23: 0 through
        !            24: .IR nfds \-1
        !            25: are considered.
        !            26: The number of ready descriptors is returned,
        !            27: and the
        !            28: .B fd_set
        !            29: pointed to by
        !            30: .I readfds
        !            31: .RI ( writefds )
        !            32: is overwritten with a set of descriptors
        !            33: ready to be read
        !            34: (written).
        !            35: The call waits until at least one descriptor is ready,
        !            36: or until
        !            37: .I milli
        !            38: milliseconds have passed.
        !            39: .PP
        !            40: Either
        !            41: .I readfds
        !            42: or
        !            43: .I writefds
        !            44: may be 0
        !            45: if no descriptors are interesting.
        !            46: .PP
        !            47: The
        !            48: .BR fd_set
        !            49: type looks like
        !            50: .RS
        !            51: .EX
        !            52: typedef struct {
        !            53:        unsigned int fds_bits[FDWORDS];
        !            54: } fd_set;
        !            55: .EE
        !            56: .RE
        !            57: .B FDWORDS
        !            58: is sufficient to contain as many file descriptors as the system will allow
        !            59: (currently 128).
        !            60: If there are
        !            61: .I B
        !            62: bits in an
        !            63: .BR "unsigned int" ,
        !            64: file descriptor
        !            65: .I n
        !            66: is represented by
        !            67: .BI "1<<((" n % B )-1)
        !            68: in word
        !            69: .BI fds_bits[ n / B ]\c
        !            70: \&.
        !            71: .PP
        !            72: These macros should be used
        !            73: to manipulate the contents
        !            74: of an
        !            75: .BR fd_set :
        !            76: .TF FD_ISSET(n,\0s)
        !            77: .TP
        !            78: .PD 0
        !            79: .B FD_ZERO(s)
        !            80: clear all bits
        !            81: in set
        !            82: .I s
        !            83: .TP
        !            84: .B "FD_SET(n, s)
        !            85: set bit for file descriptor
        !            86: .I n
        !            87: in set
        !            88: .I s
        !            89: .TP
        !            90: .B "FD_CLR(n, s)
        !            91: clear bit for file descriptor
        !            92: .I n
        !            93: in s
        !            94: .TP
        !            95: .B "FD_ISSET(n, s)
        !            96: return a value of 1
        !            97: if bit for file descriptor
        !            98: .I n
        !            99: is set in
        !           100: .IR s ,
        !           101: 0 otherwise
        !           102: .PD
        !           103: .SH EXAMPLES
        !           104: .EX
        !           105: int p[2];
        !           106: fd_set wfs;
        !           107: pipe(p);
        !           108: do {
        !           109:        FD_SET(p[1], wfs);
        !           110:        write(p[1], ".", 1);
        !           111:        i++;
        !           112: } while(select(p[1]+1, (fd_set*)0, wfs, 0) == 1);
        !           113: printf("Pipe capacity = %d\en", i);
        !           114: .EE
        !           115: .SH "SEE ALSO"
        !           116: .IR read (2)
        !           117: .SH DIAGNOSTICS
        !           118: .BR EBADF ,
        !           119: .BR EFAULT ,
        !           120: .BR EINTR
        !           121: .SH BUGS
        !           122: .I Milli
        !           123: is rounded up to the nearest second.
        !           124: .br
        !           125: .I Select
        !           126: is intended for use with streams;
        !           127: file descriptors referring to ordinary files
        !           128: or to non-stream special files
        !           129: always appear ready.
        !           130: This is a lie for some special files.

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.