#include <unistd.h> int dup2(int existing_handle, int new_handle);
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.
The new handle, or -1 on error.
not ANSI, POSIX
/* 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.