select() and read()

Hi,

Could you please tell me how can I know which position a given read descriptor ocuppies in the descriptors table.

I know that, for instance, 'stdin' ocuppies position [0]... what about the others descriptors that I create usings pipes or sockets??

Thanks!

P.S.: Sorry for my bad English

pipe() returns an array with two file descriptors. socket() returns a single file descriptor. When you say that stdin is 0, that means that it is file descriptor 0. All of the system calls in sector 2 of the manual deal with file descriptors.

If you do an fopen(), on the other hand, you do not get a file descriptor, you get a pointer to a FILE structure. To convert that into an fd, just use fileno().

Thanks, I got it! :wink: