DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

dup(S)


dup -- duplicate an open file descriptor

Syntax

cc . . . -lc

int dup (fildes)
int fildes;

Description

The fildes argument is a file descriptor obtained from a creat, open, dup, fcntl, or pipe system call. The dup system call returns a new file descriptor having the following in common with the original:

The new file descriptor is set to remain open across exec system calls. See fcntl(S).

The file descriptor returned is the lowest one available.

The dup system call fails if one or more of the following is true:


[EBADF]
The fildes argument is not a valid open file descriptor.

[EINTR]
A signal was caught during the dup system call.

[EMFILE]
NFILE file descriptors are currently open.

[ENOLINK]
fildes is on a remote machine and the link to that machine is no longer active.

Diagnostics

Upon successful completion a non-negative integer, namely the file descriptor, is returned. Otherwise, a value of -1 is returned, and errno is set to indicate the error.

See also

close(S), creat(S), exec(S), fcntl(S), open(S), pipe(S), lockf(S)

Standards conformance

dup is conformant with:

X/Open Portability Guide, Issue 3, 1989 ;
IEEE POSIX Std 1003.1-1990 System Application Program Interface (API) [C Language] (ISO/IEC 9945-1) ;
and NIST FIPS 151-1 .


© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003