How to do it…

  1. Invoke the mkfifo function to create a new FIFO special file.
  2. Open the FIFO special file in write-only mode by invoking the open function.
  3. Enter the text to be written into the FIFO special file.
  4. Close the FIFO special file.

The writefifo.c program for writing into a FIFO is as follows:

#include <stdio.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

int main()
{
int fw;
char str[255];
mkfifo("FIFOPipe", 0666);
fw = open("FIFOPipe", O_WRONLY);
printf("Enter text: ");
gets(str);
write(fw,str, sizeof(str));
close(fw);
return 0;
}

Let's go behind the scenes.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset