2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
5 ANSI C function dup2().
11 /*****************************************************************************
24 Duplicates a file descriptor.
26 The object referenced by the descriptor does not distinguish between oldd
27 and newd in any way. Thus if newd and oldd are duplicate references to
28 an open file, read(), write() and lseek() calls all move a single
29 pointer into the file, and append mode, non-blocking I/O and asynchronous
30 I/O options are shared between the references. If a separate pointer
31 into the file is desired, a different object reference to the file must be
32 obtained by issuing an additional open(2) call. The close-on-exec flag
33 on the new file descriptor is unset.
36 oldfd - The file descriptor to be duplicated
37 newfd - The value of the new descriptor we want the old one to be duplicated in
40 -1 for error or newfd on success
43 This function must not be used in a shared library or
44 in a threaded application.
51 accept(), open(), close(), fcntl(), pipe(), socket()
55 ******************************************************************************/
59 oldfdesc
= __getfdesc(oldfd
);
66 newfd
=__getfdslot(newfd
);
69 oldfdesc
->opencount
++;
70 __setfdesc(newfd
, oldfdesc
);