|
|
FIFOs, which are created by mknod(2) or mkfifo(3C) behave like regular file system nodes but are distinguished from other file system nodes by the p in the first column when the ls -l command is executed. Data written to the FIFO or read from the FIFO flow up and down the Stream in STREAMS buffers. Data written by one process can be read by another process.
FIFOs are opened in the same way as other file system nodes using the open system call. Any data written to the FIFO can be read from the same file descriptor in a FIFO manner. Modules can also be pushed on the FIFO. See open(2) for the restrictions that apply when opening a FIFO.
A STREAMS-based pipe is created by the pipe system call that returns two file descriptors, fd[0] and fd[1]. Both file descriptors are opened for reading and writing. Data written to fd[0] becomes data read from fd[1] and vice versa.
Each end of the pipe has knowledge of the other end through internal data structures. Subsequent reads, writes, and closes are aware of whether the other end of the pipe is open or closed. When one end of the pipe is closed, the internal data structures provide a way to access the Stream for the other end so that an M_HANGUP message can be sent to its Stream head.
After successful creation of a STREAMS-based pipe, 0 is returned. If pipe is unable to create and open a STREAMS-based pipe, it will fail with errno set as follows:
STREAMS modules can be added to a STREAMS-based pipe with the ioctl I_PUSH. A module can be pushed onto one or both ends of the pipe (see ``Pushing modules on a STREAMS-based pipe''). However, a pipe maintains the concept of a midpoint so that if a module is pushed onto one end of the pipe, that module cannot be popped from the other end.
Pushing modules on a STREAMS-based pipe