mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-12 11:10:07 +00:00
d32deab17b
Suggested by G. Brandon Robinson.
39 lines
695 B
Groff
39 lines
695 B
Groff
.TH DUP 3
|
|
.SH NAME
|
|
dup \- duplicate an open file descriptor
|
|
.SH SYNOPSIS
|
|
.B #include <u.h>
|
|
.br
|
|
.B #include <libc.h>
|
|
.PP
|
|
.B
|
|
int dup(int oldfd, int newfd)
|
|
.SH DESCRIPTION
|
|
Given a file descriptor,
|
|
.IR oldfd ,
|
|
referring to an open file,
|
|
.I dup
|
|
returns a new file descriptor referring to the same file.
|
|
.PP
|
|
If
|
|
.I newfd
|
|
is \-1 the system chooses the lowest available file descriptor.
|
|
Otherwise,
|
|
.I dup
|
|
will use
|
|
.I newfd
|
|
for the new file descriptor
|
|
(closing any old file associated with
|
|
.IR newfd ).
|
|
.SH SOURCE
|
|
.B \*9/src/lib9/dup.c
|
|
.SH DIAGNOSTICS
|
|
Sets
|
|
.IR errstr .
|
|
.SH BUGS
|
|
To avoid name conflicts with the underlying system,
|
|
.I dup
|
|
is a preprocessor macro defined as
|
|
.IR p9dup ;
|
|
see
|
|
.MR intro (3) .
|