⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wfifo.c

📁 ARM Linux2.4 进程间通信 非常好
💻 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 + -