Forked from
redox-os / relibc
2449 commits behind the upstream repository.
-
Dan Robertson authored
The current implementation of open requires the user to pass all three args to the function. It should use a va_list and allow a user to provide only the filename and flags.
Dan Robertson authoredThe current implementation of open requires the user to pass all three args to the function. It should use a va_list and allow a user to provide only the filename and flags.
dup.c 376 B
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
int main(int argc, char** argv) {
creat("dup.out", 0777);
int fd1 = open("dup.out", 0);
int fd2 = dup(fd1);
printf("fd %d duped into fd %d\n", fd1, fd2);
close(fd1);
close(fd2);
int fd3 = open("dup.out", 0x0002, 0x1000);
dup2(fd3, 1);
printf("hello fd %d", fd3);
close(fd3);
}