Use of select in NeWS.

Radford Neal radford at calgary.UUCP
Tue Feb 23 09:18:31 AEST 1988


The portable NeWS source code (1.0) contains the following bit
of programming:

    int readfds, writefds, exceptfds;
    ...
    max_fds = getdtablesize(); 
    ...
    select(max_fds, &readfds, &writefds, &exceptds, timeout);

I think it is worth pointing out that this is *WRONG*. The correct
approach is to pass 32 as the first parameter of select, maybe via
a constant definition.

The reason for the first parameter is to specify the size of the 
bit vectors whose addresses are passed as the 2nd, 3rd, and 4th
parameters. These bit vectors are clearly 32 bits in size.

The above code will break horribly if UNIX is ever extended to
allow more than 32 file descriptors. (Select in this case would be
able to take pointers to arrays of ints.) Passing an explicit 32 as 
the first parameter will continue to work as long as the program
isn't actualy using more than 32 files.

    Radford Neal
    The University of Calgary



More information about the Comp.unix.wizards mailing list