Team BBL
Previous Page Next Page

Exercises

17.1

Recode Figure 17.4 to use the standard I/O library instead of read and write on the STREAMS pipe.

17.2

Write the following program using the file descriptor passing functions from this chapter and the parentchild synchronization routines from Section 8.9. The program calls fork, and the child opens an existing file and passes the open descriptor to the parent. The child then positions the file using lseek and notifies the parent. The parent reads the file's current offset and prints it for verification. If the file was passed from the child to the parent as we described, they should be sharing the same file table entry, so each time the child changes the file's current offset, that change should also affect the parent's descriptor. Have the child position the file to a different offset and notify the parent again.

17.3

In Figures 17.29 and 17.30, we differentiated between declaring and defining the global variables. What is the difference?

17.4

Recode the buf_args function (Figure 17.32), removing the compile-time limit on the size of the argv array. Use dynamic memory allocation.

17.5

Describe ways to optimize the function loop in Figure 17.38 and Figure 17.39. Implement your optimizations.

    Team BBL
    Previous Page Next Page