#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
int main()
{
int fd;
char str[12]="hello world";
mkfifo("fifoa",O_CREAT|O_EXCL); //mkfifo("fifo",O_CREAT|O_EXCL);
fd=open("fifoa",O_WRONLY); //fd=open("fifo",O_WRONLY);
write(fd,str,12);
sleep(1);
close(fd);
return 0;
}
******************************************
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
int main()
{
int fd;
char str[12];
fd=open("fifoa",O_RDONLY); //fd=open("fifo",O_RDONLY);
memset(str,0,sizeof(str));
read(fd,str,12);
write(STDOUT_FILENO,str,12);
close(fd);
return 0;
}