Creating and reading a fifo file Code

Creating and reading a fifo file

 

Problem Statement : Write a Program to implementation of creating and reading a fifo file.

What is Fifo File ?

fifo file is the file is similar to a pipe in linux , except that it is accessed as part of the file system. a Fifo file can be opened by multiple processes for reading or writing simultaneously . During exchanging data using the FIFO mechanism, the kernel passes all data internally without writing it to the file system.

Creating and reading a fifo file : Reader

 [button style=”large green  embossed” link=”https://sites.google.com/site/codesgeeks/codesgeek_1/Creating%20and%20reading%20a%20fifo%20file-reader.c” target=”_blank” ]Reader Code Download[/button]

 Creating and reading a fifo file : Writer 

 [button style=”large green  embossed” link=”https://sites.google.com/site/codesgeeks/codesgeek_1/Creating%20and%20reading%20a%20fifo%20file-writer.c” target=”_blank” ]Writer Code Download[/button]

Creating and reading a fifo file Output

Sample Output 1 

mint@mint ~ $. /reader

Waiting for writers…..
Got a writer:
Read data:success
Consumer: read 5 bytes hello

mint@mint ~ $ ./writer

waiting for readers…..
Got a reader…Type some stuff
Hello
Speak:wrote 5