CSC209H5 Chapter Notes - Chapter 10: File Descriptor
Document Summary
Csc209h5s - software programming and tools (winter 2018) Notes by jonathan ho int select(numfd, read_fds, write_fds, error_fds, timeout) read_fds - specify a set of file descriptors to watch. Select blocks until one of the file descriptors have something to be read or the file descriptor is closed. A file descriptor with data is considered ready. We cannot use read_fds in a second select call. // include libraries from previous code example int main () { //fd_set - bitfield of an array of integers fd_set read_fds //declares an fd_set. // but not initialize; macros are provided set operations (adding, removing) empty. Fd_zero(&read_fds); //initializes the set of descriptors to be. // selects first parameter is the highest file descriptor of the set + 1 for efficiency int numfd; if (pipe_child1[ 0 ] > pipe_child2[ 0 ]) { numfd = pipe_child1[ 0 ] + 1 ; else { numfd = pipe_child2[ 0 ] + 1 ;