2, Pipeline (nameless pipe):
A. Can only be used to communicate between processes that have affinity;
B, half duplex mode, with fixed read and write end;
C, pipeline is not an ordinary file, does not belong to any file system, only exist in memory;
D, when a pipe is created by the function int pipe (int fd[2]), fd[0] is a fixed read end, Fd[1] is a fixed write end;
E, read and write to the pipeline, in fact, is the kernel buffer read and write;
Attention:
I, if all points to the pipe read end of the file descriptor has been closed, and the write end continues to write, you will receive a sigpipe signal, usually causes the process to terminate abnormally;
II, if all points to the end of the pipeline file descriptor has been closed, and read continues to read, the read end will continue to read the contents of the pipeline, read after reading again, will return 0, as read to the end of the file;
III, if the file pointing to the pipe is not closed to the read and write end, but the write end does not write to the pipeline data, the reader will continue to read the remaining data in the pipeline, after reading, blocking wait until the pipeline has data;
IIII, if the reading and writing end point to the pipeline is not closed, but read no data read, and the writing end is constantly writing data, when the pipeline is full, it will block the wait;
3, standard flow pipeline:
with buffers
Function: file* popen (char* command, char* type);
int Pclose (file* stream);
command refers to the path + file name;
Type represents a read-write mode, can only be one way, can not read and write at the same time, when the parameters are two, only take the first value;
WAIT4 () is called by Pclose (file* stream), waits for the pipeline process to finish running, and then closes the file stream;
This article is from the "10891086" blog, please be sure to keep this source http://10901086.blog.51cto.com/10891086/1917532
Pipeline standard flow pipeline for process communication