Chapter 44, Pipes and FIFOs
- ls -alrt | more
- Pipes and FIFOs are a basic inter-process communications mechanism.
- The are fairly primitive
- One way communication (but you can make two)
- No message separation
- Limited size
- mkfifo
- Make a file system pipe.
- This is one of the different file types (regular files, directories, FIFOs (pipes))
- Do this.
- counter > apipe
- talker < apipe
- pipe
- Needs unistd.h
- int pipe(int fildes[2]);
- Parameters
- fildes is an array of file descriptors
- fildes[0] is the read end of the pipe.
- fildes[1] is the write end of the pipe.
- writer ---> fildes[1] ----> filedes[0] ----> reader
- Return value
- dup
- needs unistd.h
- int dup(int oldfd);
- Creates a copy of oldfd at the next available file descriptor.
- int dup2(int oldfd, int newfd);
- Copies oldfd to newfd, closing newfd in required.
- Look at piper.C
- He gives several other examples.