Famous Pipeline communication

Source: Internet
Author: User

One. Famous pipes

1. Famous pipeline, also known as FIFO file, we can take action on the operation file of the famous pipe, such as using Open, Read,write.

2.FIFO file differs from normal file

(1). A process that reads a FIFO file can only open a FIFO file in "rdonly" mode.

(2). Processes that write FIFO files can only open fofo files in "wronly" mode.

(3). When the contents of the FIFO file are read, it disappears. But the contents of the normal file still exist after reading it.

Two. function Learning (create FIFO file, write data to FIFO, exit)

1. Create a pipeline

Function Name: Mkfifo

function prototypes: int mkfifo (const char *pathname,mode_t mode)

function function: Create FIFO file (named pipe)

Owning header file: <sys/types.h> <sys/stat.h>

Return value: Success: 0

Failed:-1

Parameter description: Pathname: The name of the FIFO file to be created

Mode: access rights to the FIFO file created

2. Delete a pipeline

Function Name: unlink

function prototypes: int unlink (const char *pathname)

function function: Delete file

Owning header file: <unistd.h>

Return value: When successful: returns 0

On failure: return-1

Parameter description: Pathname: Used to indicate the name of the file to be deleted

3. Open the Pipe

4. Close the pipe

5. Read the pipeline

6. Write a pipeline

Famous Pipeline 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.