Programming and posix - April 2002
April 3, 2002
Solution Symposium
Page 38
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