命名管道实习有关系的进程族之间的通信
程序在linux2.6内核编程执行通过.....
#include<stdio.h>
#include<sys/stat.h>
#include<sys/types.h>
#include<string.h>
#include<fcntl.h>
#define MAXLINE 4096
int main()
{
mkfifo("fifo.txt",S_IRWXU);
pid_t pd;
char line[MAXLINE];
long fd;
if((pd = fork())<0)
{
return 0;
}
else if(pd == 0)
{
int n;
fd = open("fifo.txt",O_RDWR);
strcpy(line,"hello");
n = strlen(line);
write(fd,line,n);
sleep(1);
close(fd);
}
else
{
int n;
fd = open("fifo.txt",O_RDWR);
n = read(fd,line,MAXLINE);
printf("%s /n %d/n",line,n);
close(fd);
}
}