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 \*9/src/lib9/dup.c30 .SH DIAGNOSTICS31 Sets32 .IR errstr .33 .SH BUGS34 To avoid name conflicts with the underlying system,35 .I dup36 is a preprocessor macro defined as37 .IR p9dup ;38 see39 .IR intro (3).