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:
“If the child knows the rewards and punishments in advance and knows that his parents will stick to them, the parents can actually empathize with the childs plight while, at the same time, creating a firm sense of structure.... Your child will sense your resolve and your empathywhether you do this with words or just a sense of warmth.”
—Stanley I. Greenspan (20th century)