In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Linux Inter-process Communication-named pipes
FIFO (named pipe) is different from anonymous pipe in that it provides two pathnames associated with it and is stored in the component system in the form of FIFO. Named pipes are "device" pieces, so even if the process is not related to the process that created the FIFO, as long as the path is accessible, they can communicate with each other through the FIFO. It is worth noting that FIFO (first input first output) always works according to the first-in-first-out principle, and the first-written data will be read out of the pipeline first.
There are two system functions for creating named pipes: mknod and mkfifo. Both functions are defined in the header sys/stat.h. The function prototype is as follows:
# include # include int mknod (const char * path,mode_t mod,dev_t dev); int mkfifo (const char * path,mode_t mode)
In the function mknod parameter, path is the full path name of the created named pipe: mod is the mode of the created named pipe, indicating its access permission; dev is the device value, which depends on the type of device created, and it will be found only when the device component is created. Both functions return 0 for success and-1 for failure. The next "make" mknod function creates a named pipe:
Umask (0); if (mknod ("/ tmp/fifo", S_IFIFO | 0666) =-1) {perror ("mkfifo error"); exit (1);}
The first two parameters of the function mkfifo have the same meaning as mknod. The following is the example code that makes the mkfifo:
Umask (0); if (mkfifo ("/ tmp/fifo", S_IFIFO | 0666) =-1) {perror ("mkfifo error!"); exit (1);}
The following is a trial example:
Read end
# include # define PATH ". / fifo" # define SIZE 128 int main () {umask (0); if (mkfifo (PATH,0666 | S_IFIFO) = =-1) {perror ("mkefifo error"); exit (0);} int fd = open (PATH,O_RDONLY); if (fd)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.