Restored work-around for hangs when trying to use disk-based handlers
[tangerine.git] / compiler / clib / dup.c
blob88517c5da98c60ec8cdfff6472c637d40724f30d
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 $Id$
5 ANSI C function dup().
6 */
8 #include <errno.h>
9 #include "__open.h"
11 /*****************************************************************************
13 NAME */
14 #include <unistd.h>
16 int dup (
18 /* SYNOPSIS */
19 int oldfd
22 /* FUNCTION
23 Duplicates a file descriptor.
25 The object referenced by the descriptor does not distinguish between oldd
26 and newd in any way. Thus if newd and oldd are duplicate references to
27 an open file, read(), write() and lseek() calls all move a single
28 pointer into the file, and append mode, non-blocking I/O and asynchronous
29 I/O options are shared between the references. If a separate pointer
30 into the file is desired, a different object reference to the file must be
31 obtained by issuing an additional open(2) call. The close-on-exec flag
32 on the new file descriptor is unset.
34 INPUTS
35 oldfd - The file descriptor to be duplicated
37 RESULT
38 -1 for error or the new descriptor.
40 The new descriptor returned by the call is the lowest numbered
41 descriptor currently not in use by the process.
43 NOTES
44 This function must not be used in a shared library or
45 in a threaded application.
47 EXAMPLE
49 BUGS
51 SEE ALSO
52 accept(), open(), close(), fcntl(), pipe(), socket()
54 INTERNALS
56 ******************************************************************************/
58 return dup2(oldfd, __getfirstfd(0));