#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <err.h>
#include "../lpi.h"

int
main(void)
{
    int fd1, fd2;

    fd1 = open("log", O_WRONLY | O_CREAT | O_EXCL);
    if (fd1 == -1)
        err(EXIT_FAILURE, "open");

    lseek(fd1, 500, SEEK_SET);

    fd2 = dup(fd1);
    if (fd2 == -1)
        err(EXIT_FAILURE, "dup");

    printf("[fd1=%d] offset=%ld\n", fd1, tell(fd1));
    printf("[fd2=%d] offset=%ld\n", fd2, tell(fd2));

    printf("%x\n", FD_CLOEXEC);
    exit(EXIT_SUCCESS);
}
