Select() arguments before FD_SET

[I am writing code for Uniflex on Tektronix 4404.]

There are no docs I can find for select() but my vague memory was that before FD_SET macros, you just created a mask by OR-ing in 1 << file descriptor

Can anyone confirm that sounds right?

Hmm there’s no mention of select in this doc
68xxx UniFLEX Introduction to UniFLEX System Calls Sep86

Is this a question of different versions?

That’s my memory of it, too. I think I was either porting code or looking at old examples and had to confirm that FD_SET was just creating a bitmask out of a small int array. And that as long as your FD’s were under 32 you could get away with a single int to store the bits.

1 Like

No, libinfo shows there is a symbol for select() (and net/select.h exists) . Its just K&R C not really saying what is expected!

Oldest K&R networky C code I have is c1991 - ran under SunOS and uses select() but it also has the FD_SET, etc. macros.

It includes:

#include <sys/socket.h>
#include <netinet/in.h>

Not sure that helps…

-Gordon

1 Like

This link confirms my recollection: select() came along with the sockets API in 4.x Berkeley Unix. This was 1982/83. It wasn’t in Unix v7 for the VAX, for example. A brief history of select(2) — Idea of the day so Ed probably guessed correctly - version issue.

@Adam_Billyard - I think the answer to your question is “yes, maybe”. The problem as @gp2000 points out is that << will only work if file descriptor is less than the number of bits in whatever size of word you’re passing into the kernel.

The source code for modern versions of FD_SET and friends is messy because processes can have lots of file descriptors, so the macro has to index an array and then shift to the correct bit. (https://github.com/openbsd/src/blob/master/sys/sys/select.h)

For really old 16-bit systems, I recall there is another subtlety: original K&R C did not define long as an “arithmetic type”. This meant that << wasn’t guaranteed to work on long. And there was a Whitesmith C compiler for the PDP-11 where it actually didn’t.

3 Likes

That’s a great link, thanks. Lots to read in there and the links within. Videos too!

+1 for the link. Excellent stuff.

Tek4404 C compiler has 4 byte ints so should be fine.

Coincidentally, when I was a postgrad in 1987, I wrote a window system for Tek4404 that allowed running multiple shells much like Blit but since I cannot access the Micropolis HD, I can’t get my code! Arghh.
So I’m attempting to reproduce it starting with getting pseudo terminals / select working.

1 Like