DUP (II) 1/15/73 DUP (II)
NAME dup -- duplicate an open file descriptor
SYNOPSIS (file descriptor in r0)
sys dup / dup = 41.; not in assembler
(file descriptor in r0)
DESCRIPTION Given a file descriptor returned from an open or
creat call, dup will allocate another file de-
scriptor synonymous with the original. The new
file descriptor is returned in r0.
Dup is used more to manipulate the value of file
descriptors than to genuinely duplicate a file
descriptor. Since the algorithm to allocate file
descriptors is known to use the lowest available
value between 0 and 9, combinations of dup and
close can be used to manipulate file descriptors
in a general way. This is handy for manipulating
standard input and/or standard output.
SEE ALSO creat(II), open(II), close(II)
DIAGNOSTICS The error bit (c-bit) is set if: the given file
descriptor is invalid; there are already 10 open
files.
BUGS --