Linux application Development-famous pipeline programming
A famous pipe
For any two process communication, known as a pipeline called FIFO file, so we
The operation of the Tao can take the method of manipulating files, such as using Open,read,write.
2 Features
FIFO files have similarities to normal files in use, but there are differences:
1. Processes that read FIFO files can only open FIFO files in "rdonly" mode.
2. The process of writing FIFO file can only open FIFO in "wronly" mode
3. When the contents of the FIFO file are read, it disappears. However, the contents of the normal file are still available after reading.
3 Correlation functions
Create a named pipe
Name of function
Mkfifo
Function prototype
int Mkfifo (const char *pathname, mode_t mode)
function function
Create a FIFO file or a well-known pipeline
Owning header file
#include <sys/types.h>
#include <sys/stat.h>
return value
Successful return 0
Failed return-1
Parameter description
Pathname: The name of the FIFO file to be created with the path of the
Mode: access rights to the FIFO file created
Remove a named pipe
Name of function
Unlink
Function prototype
int unlink (const char *pathname)
function function
deleting files including FIFO files
Owning header file
#include <unistd.h>
return value
Successful return 0
Failed return-1
Parameter description
Pathname is the name of the file that contains the path
a small case
Blocking State
unblocked.
Linux application development-famous pipeline programming