January 2003
Intermediate to advanced
480 pages
13h 22m
English
The section File Descriptors, in Chapter 2, introduced the concept of file descriptors. Typically a file descriptor is returned in response to an open() or creat() system call. The dup() system call allows a user to duplicate an existing open file descriptor.
#include <unistd.h> int dup(int fildes);
There are a number of uses for dup() that are really beyond the scope of this book. However, the shell often uses dup() when connecting the input and output streams of processes via pipes.