Pipeline standard flow pipeline for process communication

Source: Internet
Author: User


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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.