Programming and posix - February 2001

February 10, 2001
Solution Symposium
Page 37
hp e3000
programming
and posix
file management - dup()/dup2()
duplicates file descriptors
commonly used with fork()/exec() to create pipes
int dup (int fildes);
int dup2(iint fildes, int fildes2);
filedes2 specifies the desired new descriptor
number
commonly used to redirect stdin/stdout/stderr