Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/feature_fixcpp/sys/src/ape/lib/ap/plan9/dup.c – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include "lib.h"
2
#include <unistd.h>
3
#include <errno.h>
4
 
5
int
6
dup(int oldd)
7
{
8
	return fcntl(oldd, F_DUPFD, 0);
9
}
10
 
11
int
12
dup2(int oldd, int newd)
13
{
14
	if(newd < 0 || newd >= OPEN_MAX){
15
		errno = EBADF;
16
		return -1;
17
	}
18
	if(oldd == newd && _fdinfo[newd].flags&FD_ISOPEN)
19
		return newd;
20
	close(newd);
21
	return fcntl(oldd, F_DUPFD, newd);
22
}