Tuesday 23 February 2016

Assume that a process executes the following three function calls: fd1= open(pathname, oflags); fd2 = dup(fd1); fd3 = open(pathname, oflags); Draw the resulting picture, similar to Figure 3.8. Which descriptors are affected by an fcntl on fd1 with a command of F_SETFD? Which descriptors are affected by an fcntl on fd1 with a command of F_SETFL?

 Each call to open gives us a new file table entry. But since both opens reference the same file, both file table entries point to the same v-node table entry. The call to dup references the existing file table entry. We show this in Figure C.2. An F_SETFD on fd1 affects only the file descriptor flags for fd1. But an F_SETFL on fd1 affects the file table entry that both fd1 and fd2 point to.
Figure C.2. Result of dup and open






No comments:

Post a Comment