delorie.com/djgpp/doc/libc/libc_282.html   search  
libc.a reference

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

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

ANSI/ISO C No
POSIX 1003.2-1992; 1003.1-2001

Example

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


  webmaster     delorie software   privacy  
  Copyright © 2004     Updated Apr 2004