1DUP(2)                        System Calls Manual                       DUP(2)
2
3
4

NAME

6       dup, dup2 - duplicate an open file descriptor
7

SYNOPSIS

9       dup(fildes)
10       int fildes;
11
12       dup2(fildes, fildes2)
13       int fildes, fildes2;
14

DESCRIPTION

16       Given a file descriptor returned from an open, pipe, or creat call, dup
17       allocates another file descriptor synonymous with  the  original.   The
18       new file descriptor is returned.
19
20       In  the  second form of the call, fildes is a file descriptor referring
21       to an open file, and fildes2 is a non-negative integer  less  than  the
22       maximum  value  allowed  for file descriptors (approximately 19).  Dup2
23       causes fildes2 to refer to the same file as fildes.  If fildes2 already
24       referred to an open file, it is closed first.
25

SEE ALSO

27       creat(2), open(2), close(2), pipe(2)
28

DIAGNOSTICS

30       The  value  -1  is  returned  if: the given file descriptor is invalid;
31       there are already too many open files.
32

ASSEMBLER

34       (dup = 41.)
35       (file descriptor in r0)
36       (new file descriptor in r1)
37       sys dup
38       (file descriptor in r0)
39
40       The dup2 entry is implemented by adding 0100 to fildes.
41
42
43
44                                                                        DUP(2)
Impressum