home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Borland Programmer's Resource
/
Borland_Programmers_Resource_CD_1995.iso
/
utils
/
source
/
sh
/
std
/
posix
/
dup2.c
< prev
next >
Encoding:
Amiga
Atari
Commodore
DOS
FM Towns/JPY
Macintosh
Macintosh JP
Macintosh to JP
NeXTSTEP
RISC OS/Acorn
Shift JIS
UTF-8
Wrap
C/C++ Source or Header
|
1995-05-19
|
278 b
|
23 lines
/*
* Cheap imitation of BSD dup2()
*/
#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