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:

    I have heard it said
    There is an art which in their piedness shares
    With great creating nature.
    William Shakespeare (1564–1616)