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
This commit is contained in:
Axel Dörfler 2004-06-15 15:20:38 +00:00
parent 734893f6d2
commit 143691ef36
2 changed files with 22 additions and 31 deletions

View File

@ -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 <unistd.h>
#include <syscalls.h>
#include <errno.h>
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;
}

View File

@ -1,22 +0,0 @@
/*
** Copyright 2001, Manuel J. Petit. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#include <unistd.h>
#include <syscalls.h>
int
dup2(int ofd, int nfd)
{
int retval;
retval= sys_dup2(ofd, nfd);
if(retval< 0) {
// set errno
}
return retval;
}