pipe is a pipe in the Linux system. The main body of the pipe mechanism is the call of the pipe function. How do the Linux system build the pipe function? The following small series will introduce you to the method of building a pipe function in Linux. Let's take a look at it.
● unnamed pipes
mainly used between the parent and the child, or between two brothers processes. In the Linux system, a one-way communication pipeline can be established through system calls, and this relationship can only be established by the parent process. Therefore, each pipe is unidirectional, and two pipes need to be established when two-way communication is required. Processes at both ends of the pipeline treat the pipeline as a file, one process is responsible for writing to the pipeline, and the other is reading from the pipeline. This transmission follows the rules of "first in, first out" (FIFO).
● Named Pipes
Named pipes are designed to address the shortcomings of unnamed pipes that can only be used for communication between close relatives. A named pipe is a file with its own name built on the actual disk media or file system (not just in memory), and any process can contact the file at any time by file name or path name. In order to implement named pipes, a new file type ——FIFO file (following the principle of first in, first out) was introduced. Implementing a named pipe is actually implementing a FIFO file. Once a named pipe is established, its read, write, and close operations are identical to those of a normal pipe. Although the inode node of the FIFO file is on the disk, it is only a node. The file data still exists in the memory buffer page, which is the same as the normal pipe.
1. Function Description
pipe(Create Pipeline):
1) Header #include "unistd.h"
2) Define function: Int pipe(int filedes[2]);
3) Function description: pipe() will create a pipe and return the file descriptor from the parameter filedes array.
filedes[0] is the read end of the pipe
filedes[1] is the write end of the pipe.
4) Return Value: Returns zero if successful, otherwise returns -1, the cause of the error is stored in errno.
Error Code:
EMFILE Process has run out of file descriptors maximum
ENFILE The system has no file descriptors available.
EFAULT parameter filedes The array address is invalid.
Previous12Next Total 2 Pages
When there is still a lot of space on the Linux system hard disk, we can use the fd
We all know that Linux can be operated with a variety of commands, there are quite a few commands fo
Generally speaking, the number of subfolders and files in the system is very large, we cant count th
The fork() function is a fork function. An existing process can call the fork() fun
Summary of lftp usage in Linux system
What can I do if I cannot mount NTFS after installing Ubuntu?
Linux system uses the command line to execute the php file transfer step
How to install and use Makeself
Linux installation using the compression tool 7-zip steps
How to install Mongo extensions on Linux systems
Ubuntu system installation screen saver XScreenSaver steps
Linux function library creation method
Linux can not log in mysql how to do?
How to use the command to delete and create the Linux folder
What should I do if ORA-12528 reports an error when building DataGuard in Linux?
(Figure) Win10 Build 10135 get started experience atlas: RTM preview version is close to
Win7 killing virus found win32k.sys file can be deleted?
Which 4G memory stick can be installed on this computer
How to close the set of win8 computer only use the single display
Six steps to easily get the win7 system prompt disk is protected
Win7 open file prompt "references an unavailable location" response
Win7 restores the method of pressing the right-click menu
How to get back the sleep mode of the Windows 7 system forgotten