home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Geek Gadgets 1
/
ADE-1.bin
/
ade-dist
/
pdksh-4.9-src.tgz
/
tar.out
/
contrib
/
pdksh
/
std
/
posix
/
dup2.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-09-28
|
330b
|
24 lines
/*
* Cheap imitation of BSD dup2()
*/
/* $Id: dup2.c,v 1.3 93/05/05 21:17:43 sjg Exp $ */
#include <fcntl.h>
#if _SYSV
int
dup2( oldd, newd )
int oldd, newd;
{
int fd;
if (fcntl( oldd, F_GETFL, 0 ) < 0)
return( -1 );
(void) close( newd );
fd = fcntl( oldd, F_DUPFD, newd );
return( (fd > newd) ? -1 : fd );
}
#endif