From 78d3a60c53b634369eec9f44bc6006afecf21728 Mon Sep 17 00:00:00 2001 From: Bill Joy Date: Thu, 15 Nov 1979 08:41:29 -0800 Subject: [PATCH 1/1] BSD 3 development Work on file usr/man/man2/dup.2 Synthesized-from: 3bsd --- usr/man/man2/dup.2 | 68 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 usr/man/man2/dup.2 diff --git a/usr/man/man2/dup.2 b/usr/man/man2/dup.2 new file mode 100644 index 0000000000..42450d306e --- /dev/null +++ b/usr/man/man2/dup.2 @@ -0,0 +1,68 @@ +.TH DUP 2 +.SH NAME +dup, dup2 \- duplicate an open file descriptor +.SH SYNOPSIS +.B dup(fildes) +.br +.B int fildes; +.PP +.B dup2(fildes, fildes2) +.br +.B int fildes, fildes2; +.SH DESCRIPTION +Given +a file descriptor returned from +an +.I open, +.I pipe, +or +.I creat +call, +.I dup +allocates another file descriptor +synonymous +with +the original. +The new file descriptor is returned. +.PP +In the second form of the call, +.I fildes +is a file descriptor referring to an open file, and +.I fildes2 +is a non-negative integer less than the maximum value +allowed for file descriptors (approximately 19). +.I Dup2 +causes +.I fildes2 +to refer to the same file as +.I fildes. +If +.I fildes2 +already referred to an open file, it is closed first. +.SH "SEE ALSO" +creat(2), open(2), close(2), pipe(2) +.SH DIAGNOSTICS +The value \-1 is returned if: +the given file descriptor is invalid; +there are already too many open files. +.SH "ASSEMBLER (PDP-11)" +(dup = 41.) +.br +(file descriptor in r0) +.br +(new file descriptor in r1) +.br +.B sys dup +.br +(file descriptor in r0) +.PP +The +.I dup2 +entry is implemented by adding 0100 to +.I fildes. +.SH BUGS +Dup2 fails if +.I fildes2 +was +.I vread +from and some of the pages have not been referenced. -- 2.20.1