日期:2014-05-16 浏览次数:20839 次
#include<sys/types.h>
#include<sys/stat.h>
#include<unistd.h>
#include<stdio.h>
#include<fcntl.h>
#include<string.h>
int main(){
    if(mkfifo("testfifo",O_CREAT|O_RDWR) == -1)
    {    
        perror("mkfifo");
        return 0;
    }
    int fd; 
    if((fd=open("testfifo",O_WRONLY,0100)) == -1){
        perror("open");
        return 0;
    }
    char buf[]="test data.........";
    int len=strlen(buf);
    if(write(fd,buf,len) == -1){
        perror("write");
        return 0;
    }
    
    return 0;
}