From 143691ef3605a2714646f9d059bb43c603aad4be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 15 Jun 2004 15:20:38 +0000 Subject: [PATCH] New dup.c - it now contains dup() and dup2() which makes dup2.c legacy. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7964 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/libroot/posix/unistd/dup.c | 31 ++++++++++++++++++-------- src/kernel/libroot/posix/unistd/dup2.c | 22 ------------------ 2 files changed, 22 insertions(+), 31 deletions(-) delete mode 100644 src/kernel/libroot/posix/unistd/dup2.c diff --git a/src/kernel/libroot/posix/unistd/dup.c b/src/kernel/libroot/posix/unistd/dup.c index f2acdb85d0..c5fb7aa5b3 100644 --- a/src/kernel/libroot/posix/unistd/dup.c +++ b/src/kernel/libroot/posix/unistd/dup.c @@ -1,22 +1,35 @@ /* -** Copyright 2001, Manuel J. Petit. All rights reserved. -** Distributed under the terms of the NewOS License. +** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the OpenBeOS License. */ + #include #include +#include int dup(int fd) { - int retval; - - retval= sys_dup(fd); - - if(retval< 0) { - // set errno + int status = _kern_dup(fd); + if (status < 0) { + errno = status; + status = -1; } - return retval; + return status; +} + + +int +dup2(int oldFD, int newFD) +{ + int status = _kern_dup2(oldFD, newFD); + if (status < 0) { + errno = status; + status = -1; + } + + return status; } diff --git a/src/kernel/libroot/posix/unistd/dup2.c b/src/kernel/libroot/posix/unistd/dup2.c deleted file mode 100644 index 9779af686f..0000000000 --- a/src/kernel/libroot/posix/unistd/dup2.c +++ /dev/null @@ -1,22 +0,0 @@ -/* -** Copyright 2001, Manuel J. Petit. All rights reserved. -** Distributed under the terms of the NewOS License. -*/ - -#include -#include - - -int -dup2(int ofd, int nfd) -{ - int retval; - - retval= sys_dup2(ofd, nfd); - - if(retval< 0) { - // set errno - } - - return retval; -}