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