
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <inttypes.h>


int main(int argc, char **argv) {
        int fd1 = open("/etc/passwd", O_RDONLY);
        int fd2 = dup(fd1);
        char buf[19];

        printf("fd#%d read: %d\n", read(fd1, buf, sizeof(buf)));
        printf("fd#%d: pos: %"PRIdPTR"\n", fd1, lseek(fd1, 0, SEEK_CUR));
        printf("fd#%d: pos: %"PRIdPTR"\n", fd2, lseek(fd2, 0, SEEK_CUR));
        return 0;
}
