diff options
| -rw-r--r-- | src/unistd/dup2.c | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/src/unistd/dup2.c b/src/unistd/dup2.c index 2755fbc7..ba709a3c 100644 --- a/src/unistd/dup2.c +++ b/src/unistd/dup2.c @@ -4,26 +4,13 @@ #include "fcntl.h" #include "limits.h" #include "errno.h" +#include "_syscall.h" int dup2(int fildes, int fildes2) { - if (fildes2 < 0 || fildes2 >= _POSIX_OPEN_MAX) { - errno = EBADF; - return -1; - } - - if (fildes == fildes2) { - return fildes2; - } - - if (fcntl(fildes, F_GETFD) == -1) { - errno = EBADF; - return -1; - } - - close(fildes2); - return fcntl(fildes, F_DUPFD, fildes2); + SYSCALL(dup2, int, -1, fildes, fildes2, 0, 0, 0, 0); } + /* POSIX(1) */ |
