Pipeline (Unix) - Creating Pipelines Programmatically

Creating Pipelines Programmatically

Pipelines can be created under program control. The Unix pipe system call asks the operating system to construct a new anonymous pipe object. This results in two new, opened file descriptors in the process: the read-only end of the pipe, and the write-only end. The pipe ends appear to be normal, anonymous file descriptors, except that they have no ability to seek.

To avoid deadlock and exploit parallelism, the Unix process with one or more new pipes will then, generally, call fork to create new processes. Each process will then close the end(s) of the pipe that it will not be using before producing or consuming any data. Alternatively, a process might create a new thread and use the pipe to communicate between them.

Named pipes may also be created using mkfifo or mknod and then presented as the input or output file to programs as they are invoked. They allow multi-path pipes to be created, and are especially effective when combined with standard error redirection, or with tee.

Read more about this topic:  Pipeline (Unix)

Famous quotes containing the word creating:

    “Perestroika basically is creating material incentives for the individual. Some of the comrades deny that, but I can’t see it any other way. In that sense human nature kinda goes backwards. It’s a step backwards. You have to realize the people weren’t quite ready for a socialist production system.”
    —Gus Hall (b. 1910)