up | Inhaltsverzeichniss | Kommentar

Manual page for dup(2)

dup - duplicate an open file descriptor

SYNOPSIS

#include <unistd.h>

int dup(int fildes);

DESCRIPTION

dup() returns a new file descriptor having the following in common with the original open file descriptor fildes:

Same open file (or pipe).

Same file pointer (that is, both file descriptors share one file pointer).

Same access mode (read, write or read/write).

The new file descriptor is set to remain open across exec functions (see fcntl.2

The file descriptor returned is the lowest one available.

The dup(fildes) is equivalent to

fcntl( fildes, F_DUPFD, 0 )

RETURN VALUES

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.

ERRORS

dup() will fail if one or more of the following are true:

EBADF
fildes is not a valid open file descriptor.
EINTR
A signal was caught during the dup() function.
EMFILE
The process has too many open files (see getrlimit.2
ENOLINK
fildes is on a remote machine and the link to that machine is no longer active.

ATTRIBUTES

See attributes.5 for descriptions of the following attributes:

+---------------+-------------------+
|ATTRIBUTE TYPE |  ATTRIBUTE VALUE  |
+---------------+-------------------+
|MT-Level       | Async-Signal-Safe |
+---------------+-------------------+

SEE ALSO

close.2 creat.2 exec.2 fcntl.2 getrlimit.2 open.2 pipe.2 dup2.3c lockf.3c attributes.5


index | Inhaltsverzeichniss | Kommentar

Created by unroff & hp-tools. © by Hans-Peter Bischof. All Rights Reserved (1997).

Last modified 07/October/97