Named Pipes (FIFO) is a way of interprocess communication, with the following demo:
//Write ProcessintMainintargcChar**argv) { CharFilename[] ="/tmp/my_fifo"; if(Mkfifo (filename,0777) <0) {perror ("Mkfifo Error"); Exit (1); } intFD =open (filename, o_wronly); Charbuffer[ -] ="Hello World"; Write (fd, buffer, strlen (buffer)); printf ("Write done\n"); return 0;}//Read ProcessintMainintargcChar**argv) { CharFilename[] ="/tmp/my_fifo"; intFD =open (filename, o_rdonly); Charbuffer[ -]; intn = read (fd, buffer, -); Buffer[n]=' /'; printf ("input is:%s\n", buffer); return 0;}
Two places to be aware of:
1. Mkfifo will create the file in the/tmp directory MY_FIFO
2. The write process is blocked before the read process open
(It has-to-be-open at both ends simultaneously before-can proceed to does any input or output operations on it.)
Named pipes can be used for communication between any of the two processes, compared to a pipeline.
Named Pipes for interprocess communication