Go to the first, previous, next, last section, table of contents.


dup2

Syntax

#include <unistd.h>

int dup2(int existing_handle, int new_handle);

Description

This call causes new_handle to refer to the same file and file pointer as existing_handle. If new_handle is an open file, it is closed.

Return Value

The new handle, or -1 on error.

Portability

not ANSI, POSIX

Example

/* copy new file to stdin stream */
close(0);
dup2(new_stdin, 0);
close(new_stdin);


Go to the first, previous, next, last section, table of contents.