Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ dup2(2) — CX/UX 6.20

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

dup(2)

accept(2)

open(2)

close(2)

pipe(2)

socket(2)

socketpair(2)

getdtablesize(2)

dup2(2)  —  4 BSD

NAME

dup2 − duplicate a descriptor

SYNOPSIS

int dup2 (oldd, newd)
int oldd, newd;

DESCRIPTION

dup2 duplicates file descriptor oldd. The desired value of the new descriptor, newd, is specified. If this descriptor is already in use, the descriptor is first deallocated as if a close(2) call had been done first. 

RETURN VALUE

The value −1 is returned if an error occurs in either call.  The external variable errno indicates the cause of the error. 

ERRORS

dup2 fails if:

[EBADF] Oldd or newd is not a valid active descriptor. 

[EMFILE] Too many descriptors are active. 

SEE ALSO

dup(2), accept(2), open(2), close(2), pipe(2), socket(2), socketpair(2), getdtablesize(2). 

CX/UX Programmer’s Reference Manual

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