The Pipe file manager handles control or processes that use paths to pipes. Pipes allow concurrently executing processes to send each other data by using the output of one process (the writer) as input to a second process (the reader). The reader gets input from the standard input. The exclamation point (!) operator specifies that the input or output is from or to a pipe. The Pipe file manager allocates a 256-byte block and a path descriptor for data transfer. The Pipe file manager also determines which process has control of the pipe. The Pipe file manager has the standard file manager branch table at its entry point:
ENTRY LBRA Create
LBRA Open
LBRA MakDir
LBRA ChgDir
LBRA Delete
LBRA Seek
LBRA PRead
LBRA PWrite
LBRA PRdLn
LBRA PWrLn
LBRA GetStat
LBRA SetStat
LBRA Close
You cannot use MakDir, ChgDir, Delete, and Seek with pipes. If you try to do so, the system returns E$UNKSVC (unknown service request). GetStat and SetStat are also no-action service routines. They return without error.
Create and Open perform the same functions. They set up the 256-byte data exchange buffer and save several addresses in the path descriptor.
The Close request checks to see if any process is reading or writing through the pipe. If not, NitrOS-9 returns the buffer.
PRead, PWrite, PRdLn, and PWrLn read data from the buffer and write data to it.
The ! operator tells the Shell that processes wish to communicate through a pipe. For example:
poc1 ! proc2
In this example, shell forks Proc1 with the standard output path to a pipe and forks Proc2 with the standard input path from a pipe.
Shell can also handle a series of processes using pipe. For example:
proc1 ! proc2 ! proc3 ! proc4
The following outline shows how to set up pipes between processes:
Example: The following example shows how an application can initiate another process with the stdin and stdout routed through a pipe: