Next: FIFOs
Up: Pipes
Previous: Communication Between Parent and
Contents
- Frequently, you will want to create a child process and set up one end of a pipe as its standard input or standard output.
- Using the dup2 call, you can equate one file descriptor with another.
dup2(fd,STDIN_FILENO);
- The symbolic constant STDIN_FILENO represents the file descriptor for the standard input, which has the value 0.
- The following http://siber.cankaya.edu.tr/SystemsProgramming/cfiles/dup2.cprogram, (see Fig. 6.4.2) uses dup2 to send the output from a pipe to the sort command.
Figure 6.9:
Redirect Output from a Pipe with dup2
|
Cem Ozdogan
2007-05-16