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