CSC209H5 Chapter Notes - Chapter 8: Grep, C String Handling, Standard Streams

47 views6 pages

Document Summary

Csc209h5s - software programming and tools (winter 2018) Open a file using a file descriptor int filedes = open( file1 , o_rdonly); Create a pipe - set up a communication channel int fd[ 2 ]; // array of two file descriptors pipe(fd); Read 256 bytes from file read(filedes, buf, 256 ); Read 256 bytes from pipe read(fd[ 0 ], buf, 256 ); The file descriptor for standard output has the value 1 and is a field in a file struct. Specified by an array of two file descriptors, one for reading data from the pipe and one for writing data to the pipe. When a program calls the pipe system call, the os creates the pipe data structures and opens two file descriptors on pipe. Index 0 of array is used for reading. Index 1 of array is used for writing. When fork makes a copy of the existing progress, it also makes a copy of the open file descriptors.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents