Famous Pipeline communication programming

Source: Internet
Author: User

Create 2 processes, create a well-known pipeline in a process, write data to it, and read the data from the well-known pipeline through the B process.

A well-known pipeline, also known as a named pipe, can be used for communication between unrelated processes, similar to files in some features.

Usage: Create a named pipeline through Mkfifo, and then you can manipulate the normal file to manipulate it by using open (), close (), write (), and read ().

1. Create a famous pipe--mkfifo

Header files: #include <sys/types.h>, #include <sys/stat.h>

Prototype: int Mkfifo (const char *pathname,mode_t mode);

Parameter description: Pathname: Create the name of the pipeline corresponding to the real-name file path, Mkfifo () will be based on parameters to establish a special FIFO file, the file must not exist, mode: file permissions.

Return value: Successfully returned 0, failed to return-1, the cause of the error is stored in errno.

2, delete the famous pipe (essentially a file)---unlink

Header files: #include <unistd.h>

Prototype: int unlink (const char *pathname);

Parameter description: pathname: Named pipe file pathname

Return value: Successfully returned 0, failed to return-1, the cause of the error is stored in errno.

Fifo_write.c

Famous Pipeline communication programming

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.