previous | start | next

11.5

    1   int main()
    2   {
    3     int fd1, fd2;
    4     char c;
    5   
    6     fd1 = open("foobar.txt", O_RDONLY, 0);
    7     fd2 = open("foobar.txt", O_RDONLY, 0);
    8     read(fd2, &c, 1);
    9     dup2(fd2, fd1);
   10     read(fd1, &c, 1);
   11     printf("c = %c\n", c);
   12     exit(0);
   13   }


previous | start | next