blob: 392e6fe633e114e81762ecbfe3895a47fd041920 [file] [log] [blame]
rsccfa37a72004-04-10 18:53:55 +00001.TH DUP 3
2.SH NAME
3dup \- duplicate an open file descriptor
4.SH SYNOPSIS
5.B #include <u.h>
6.br
7.B #include <libc.h>
8.PP
9.B
10int dup(int oldfd, int newfd)
11.SH DESCRIPTION
12Given a file descriptor,
13.IR oldfd ,
14referring to an open file,
15.I dup
16returns a new file descriptor referring to the same file.
17.PP
18If
19.I newfd
20is \-1 the system chooses the lowest available file descriptor.
21Otherwise,
22.I dup
23will use
24.I newfd
25for the new file descriptor
26(closing any old file associated with
27.IR newfd ).
rsccfa37a72004-04-10 18:53:55 +000028.SH SOURCE
rscc3674de2005-01-11 17:37:33 +000029.B \*9/src/lib9/dup.c
rsccfa37a72004-04-10 18:53:55 +000030.SH DIAGNOSTICS
31Sets
32.IR errstr .
rsc058b0112005-01-03 06:40:20 +000033.SH BUGS
rscc8b63422005-01-13 04:49:19 +000034To avoid name conflicts with the underlying system,
35.I dup
36is a preprocessor macro defined as
37.IR p9dup ;
38see
rsc058b0112005-01-03 06:40:20 +000039.IR intro (3).