Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ dup(2) — AIX PS/2 1.2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

close, closex

dup2

exec: execl, execv, execle, execve, execlp, execvp

fcntl, flock, lockf

open, openx, creat

pipe

socket

socketpair



DUP(2,L)                    AIX Technical Reference                    DUP(2,L)



-------------------------------------------------------------------------------
dup



PURPOSE

Duplicates an open file descriptor.

SYNTAX

int dup (fildes)
int fildes;

DESCRIPTION

The dup system call returns a new file descriptor for the file descriptor
pointed to by the fildes parameter.  The fildes parameter is a file descriptor
obtained from a creat, open, dup, fcntl, or pipe system call, or from the
socket or socketpair subroutine.  The dup system call returns a new file
descriptor having the following in common with the original:

  o The same open file or pipe
  o The same file pointer (that is, both file descriptors share one file
    pointer)
  o The same access mode (read, write or read/write)
  o The same file status flags
  o The same locks.

The new file descriptor is set to remain open across exec system calls.  If the
Transparent Computing Facility is installed, the new file descriptor is also
set to remain open across rexec and run system calls.  (For more information
about file control, see "fcntl, flock, lockf.")

The file descriptor returned is the lowest one available.

RETURN VALUE

Upon successful completion, a file descriptor (nonnegative integer) is
returned.  If the dup system call fails, a value of -1 is returned, and errno
is set to indicate the error.

ERROR CONDITIONS

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

EBADF   fildes is not a valid open file descriptor.

EMFILE  Two hundred (200) file descriptors are currently open.

RELATED INFORMATION




Processed November 7, 1990         DUP(2,L)                                   1





DUP(2,L)                    AIX Technical Reference                    DUP(2,L)



In this book:  "close, closex," "dup2," "exec:  execl, execv, execle, execve,
execlp, execvp," "fcntl, flock, lockf," "open, openx, creat," "pipe," "socket,"
and "socketpair."




















































Processed November 7, 1990         DUP(2,L)                                   2



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026