home *** CD-ROM | disk | FTP | other *** search
-
-
-
- DUP(3) MINTLIB LIBRARY FUNCTIONS DUP(3)
-
-
- N✓NA✓AM✓ME✓E
- dup, dup2 - duplicate a file descriptor
-
- S✓SY✓YN✓NO✓OP✓PS✓SI✓IS✓S
- #include <unistd.h>
-
- int dup(int fd);
-
- int dup2(int fd1, int fd2);
-
- D✓DE✓ES✓SC✓CR✓RI✓IP✓PT✓TI✓IO✓ON✓N
- dup duplicates an existing file descriptor. The argument
- fd is a small non-negative integer index in the per-
- process descriptor table. The new descriptor returned by
- the call is the lowest numbered descriptor that is not
- currently in use by the process.
-
- With dup2, fd2 specifies the desired value of the new
- descriptor. If descriptor fd2 is already in use, it is
- first deallocted as if it were closed by close.
-
- The new descriptor has the following in common with the
- original:
-
- - It refers to the same object that the old
- descriptor referred to.
-
- - It uses the same seek pointer as the old descriptor
- (that is, both file descriptors share one seek pointer).
-
- - It has the same access mode (read, write or read/write)
- as the old descriptor.
-
- Thus if fd2 and fd1 are duplicate references to an open
- file, read, write, and lseek calls all move a single seek
- pointer into the file, and append mode is shared between
- the references. If a separate seek pointer into the file
- is desired, a different object reference to the file must
- be obtained by issuing an additional open call.
-
- R✓RE✓ET✓TU✓UR✓RN✓N V✓VA✓AL✓LU✓UE✓ES✓S
- dup and dup2 return a new descriptor on success. On fail-
- ure, they return -1 and set errno to indicate the error.
-
- S✓SE✓EE✓E A✓AL✓LS✓SO✓O
- c✓cl✓lo✓os✓se✓e(✓(3✓3)✓),✓, f✓fc✓cn✓nt✓tl✓l(✓(3✓3)✓),✓, l✓ls✓se✓ee✓ek✓k(✓(3✓3)✓),✓, o✓op✓pe✓en✓n(✓(3✓3)✓),✓, p✓pi✓ip✓pe✓e(✓(3✓3)✓),✓, r✓re✓ea✓ad✓d(✓(3✓3)✓),✓,
- w✓wr✓ri✓it✓te✓e(✓(3✓3)✓),✓, F✓Fd✓du✓up✓p(✓(2✓2)✓),✓, F✓Ff✓fo✓or✓rc✓ce✓e(✓(2✓2)✓),✓, F✓Fc✓cn✓nt✓tl✓l(✓(2✓2)✓)
-
-
-
-
-
-
-
-
-
-
- MiNT docs 0.1 3 March 1993 1
-
-
-