dup2(int src_descriptor, int dst_descriptor) creates a new file descriptor referring to the same file; it is, however, a new file descriptor.
i.e.
int fd1,fd2;
...
..
fd1 = open("/tmp/test", O_RDWR);
dup2(fd1,fd2)
lseek(fd1, SEEK_END,0);
...
..
fd1 and fd2 refer to the same file; however, the file pointer associated with the fd1 descriptor is still in the beginning of the file, fd1 points to the end. They are the same file, but not the same descriptor. HTH.
Regards
Meredith Shaebanyan
|