If fd is 1, then the dup2(fd, 1) returns 1 without
closing descriptor 1. (Remember our discussion of this in Section 3.12.) After
the three calls to dup2, all three descriptors point to the same file table
entry. Nothing needs to be closed.
If fd is 3, however, after the three calls to dup2, four descriptors are pointing to the same file table entry. In this case, we need to close descriptor 3.
If fd is 3, however, after the three calls to dup2, four descriptors are pointing to the same file table entry. In this case, we need to close descriptor 3.
No comments:
Post a Comment