DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

dup(S-osr5)


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-osr5).

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-osr5), creat(S-osr5), exec(S-osr5), fcntl(S-osr5), open(S-osr5), pipe(S-osr5), lockf(S-osr5)

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 .


© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005