dup2
Forces the file handle to reference the same open file as the handle parameter (supported only for NetWare 4.x and above)
#include <unistd.h>
int dup2 (
int handle,
int handle2);
When an error occurs, a value of -1 is returned. Otherwise, the return value is a nonnegative integer that is the file handle.
If an error occurs, errno can be set to:
The handle parameter must be a handle to a file that is already open. If handle2 references a file that is already open, that file is closed before handle2 is forced to reference the file for handle.