File:  [Research Unix] / researchv10dc / dist / man / v4 / man2 / dup.2
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:21:34 2018 UTC (8 years, 1 month ago) by root
Branches: belllabs, MAIN
CVS tags: researchv10, HEAD
researchv10 Dan Cross

.th DUP II 8/5/73
.sh NAME
dup \*- duplicate an open file descriptor
.sh SYNOPSIS
(dup = 41.; not in assembler)
.br
(file descriptor in r0)
.br
.ft B
sys dup
.s3
dup(fildes)
.br
int fildes;
.ft R
.sh DESCRIPTION
Given
a file descriptor returned from
an
.it open,
.it pipe,
or
.it creat
call,
.it dup
will allocate another file descriptor
synonymous
with
the original.
The new file descriptor is returned in r0.
.s3
.it Dup
is used more to reassign the value
of file descriptors
than to genuinely
duplicate a file descriptor.
Since the algorithm to allocate
file descriptors
returns the
lowest available
value between 0 and 9,
combinations of
.it dup
and
.it close
can be
used to
manipulate file descriptors
in a general way.
This is handy for
manipulating standard input and/or
standard output.
.sh "SEE ALSO"
creat(II), open(II), close(II), pipe(II)
.sh DIAGNOSTICS
The
error bit (c-bit)
is set if:
the given file descriptor is invalid;
there are already 10 open files.
From C, a \*-1 returned value indicates an error.

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.