Line 16: |
Line 16: |
| </pre> | | </pre> |
| | | |
− | what's next? | + | what's next? In Linux there's a cool system call dup2() which assigns to a file referenced by one file descriptor some other one, given by the caller. |
| + | So the code would look like this: |
| + | <pre> |
| + | int fd; |
| + | |
| + | fd = open_a_file(fd->file); |
| + | dup2(fd, fd->tgt_fd); |
| + | close(fd); |
| + | </pre> |
| + | |
| + | [[Category:Under the hood]] |