12th Lesson-Famous pipe communication

Source: Internet
Author: User

1. Famous pipeline: Also known as FIFO file.
2.man commands: 1. System commands, 2. System calls, 3 library functions
3. Function Learning
5.2 Create a named pipe
5.2. 1 Name of function
Mkfifo
5.2.2 Function prototype
int Mkfifo (const char *pathname, mode_t mode);
5.2.3 function function
Create a FIFO file (named pipe)
5.2.4 Owning header file
<sys/types.h>
<sys/stat.h>
5.2.5 return value
Success: 0
failed: -1
5.2.6 Parameter Description
Pathname: Name of the FIFO file to be created (with path)
Mode: Access, digital form means yes (0666)


5.3 Remove a named pipe5.3. 1 Name of function
Unlink5.3.2 Function prototype
int unlink (const char *pathname);5.3.3 function function
Deleting Files5.3.4 Owning header file
<unistd.h>5.3.5 return value
Success: 0failed: -1
5.3.6 Parameter DescriptionPathname: Used to indicate the name of the file to be deleted (with path)

the difference between 4.FIFO files and ordinary files
(1) write only when the write is open(2) Read-only open
(3) content no longer exists after reading

Other operations are done with ordinary files. 5. General Examples
(1) Write file process---"Create FIFO
---"Open and write---"Closed
(2) Read the file process---"Reading the file
---"Print---"Closed
---Delete a named pipe


6. If there is no read process access FIFO, the write process is blocked until a process accesses the FIFO to end the write process.

12th Lesson-Famous pipe 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.