📄 wfifo.c
字号:
/*********************************************************************
* File: wfifo.c
* Author: Embest J.Zhao 2005.2.17
* Desc: write FIFO,with read program rfifo.c
* History:
*********************************************************************/
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <asm/limits.h>
int main(void)
{
int nFd; /* FIFO */
int nLen; /* FIFO read bytes len */
char szBuf[PIPE_BUF]; /* FIFO buf */
mode_t mode = 666; /* FIFO */
/* creat FIFO */
if ((nFd = mkfifo("/var/ff", mode)) < 0)
{
printf("creat fifo error\n");
exit(-1);
}
/* open FIFO write port */
if ((nFd = open("/var/ff", O_WRONLY)) < 0)
{
printf("open the fifo write error\n");
exit(-1);
}
/* 写fifo */
nLen = sprintf(szBuf, "wfifo send the message");
if (write(nFd, szBuf, nLen + 1) < 0)
{
printf("open the fifo write error\n");
close(nFd);
exit(-1);
}
close(nFd);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -