Blob
1 .TH DUP 32 .SH NAME3 dup \- duplicate an open file descriptor4 .SH SYNOPSIS5 .B #include <u.h>6 .br7 .B #include <libc.h>8 .PP9 .B10 int dup(int oldfd, int newfd)11 .SH DESCRIPTION12 Given a file descriptor,13 .IR oldfd ,14 referring to an open file,15 .I dup16 returns a new file descriptor referring to the same file.17 .PP18 If19 .I newfd20 is \-1 the system chooses the lowest available file descriptor.21 Otherwise,22 .I dup23 will use24 .I newfd25 for the new file descriptor26 (closing any old file associated with27 .IR newfd ).28 .SH SOURCE29 .B /usr/local/plan9/src/lib9/dup.c30 .SH DIAGNOSTICS31 Sets32 .IR errstr .33 .SH BUGS34 .I Dup35 is a macro for36 .I p9dup37 to avoid name conflicts with the Unix function; see38 .IR intro (3).