Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ dup(2) — HP-UX 6.20

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

close(2)

creat(2)

dup2(2)

exec(2)

fcntl(2)

open(2)

pipe(2)

DUP(2)  —  HP-UX

NAME

dup − duplicate an open file descriptor

SYNOPSIS

int dup (fildes)
int fildes;

DESCRIPTION

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

Same open file (or pipe). 

Same file pointer (i.e., both file descriptors share one file pointer). 

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

Same file status flags (see fcntl(2), F_DUPFD). 

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

The file descriptor returned is the lowest one available. 

ERRORS

Dup will fail if one or more of the following are true:

[EBADF] Fildes is not a valid open file descriptor. 

­[EMFILE] The maximum number of file descriptors are currently open. 

RETURN VALUE

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. 

AUTHOR

Dup was developed by AT&T Bell Laboratories and the Hewlett-Packard Company. 

SEE ALSO

close(2), creat(2), dup2(2), exec(2), fcntl(2), open(2), pipe(2). 

Hewlett-Packard Company  —  May 11, 2021

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