fifo write

时间:2021-08-20 17:18:53
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h> #define MYFIFO "/tmp/myfifo" int main(int argc, char *argv[])
{
int fd;
char buf_w[]; fd=open(MYFIFO,O_WRONLY|O_NONBLOCK,);
if(fd==-)
{
printf("Open the FIFO is fail!\n");
if(errno==ENXIO)
printf("There is no Read FIFO!\n");
exit();
}
memset(buf_w,,sizeof(buf_w));
strcpy(buf_w,argv[]);
if(write(fd,buf_w,)<)
{
printf("Write data to FIFO fail!\n");
}
else
{
printf("Write data are: %s\n",buf_w);
} return ;
}